[BUG] OOM crash during subagent execution (8GB heap)
### Environment
- Claude Code: 2.1.7
- Node.js: 25.2.1 (Homebrew)
- OS: macOS Darwin 24.6.0 (Apple Silicon)
- Project: ~56,000 files, 7 custom subagents in .claude/agents/
### Problem
Fresh session crashes with OOM during subagent execution after minimal operations.
### Reproduction
- Fresh
claudesession (no --resume) - Simple code review request referencing one file
- Main agent reads ~500 lines, delegates to custom subagent
- Subagent performs ~25 tool uses (Search, Read operations)
- Crash at 8.1GB heap after 67 seconds
### Session log
❯ check RunAssets in @app/queries/assets_query.py [simple question]
⎿ Read app/queries/assets_query.py (250 lines)
⏺ Read(app/domain/run.py) - 265 lines
⏺ Search (2x)
⏺ domain-engineer(Refactor RunAssets dataclass)
⎿ 25+ tool uses
· Ionizing… (1m 7s · ↓ 1.9k tokens)
--- CRASH ---
### Error
Mark-Compact 8118.2 (8221.8) -> 8116.0 (8169.3) MB
average mu = 0.21
FATAL ERROR: Ineffective mark-compacts near heap limit
### What I tried
NODE_OPTIONS="--max-old-space-size=8192"→ crashes at 8GBNODE_OPTIONS="--max-old-space-size=16384"→ crashes at 16GB--dangerously-skip-permissions→ same crash- State file ~/.claude.json is only 48KB
- Added .claudeignore excluding .venv, __pycache__, node_modules
### Expected behavior
Reading 500 lines of code + 25 subagent tool calls should not require 8GB+ memory.
### Hypothesis
Memory leak during subagent execution - tool results not being garbage collected, or subagent context accumulating in parent process.
---
The issue description was made by claude code itself, but I am confirm the issue
The crashes started once the CC was updated 2.0.76 -> 2.1.6
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗