[BUG] Memory spikes during high tool fan-out in Explore mode on macOS (2.1.68)
Preflight Checklist
- [x] I searched existing issues and did not find this exact case (related but different: #20369)
- [x] This is a single bug report
- [x] I am using the latest Claude Code
What's Wrong?
When Claude Code does a broad Explore pass and triggers a high number of tool calls in one turn (roughly 30+), memory usage spikes very quickly and my Mac becomes sluggish or freezes.
I can reproduce this on the latest version (2.1.68).
Important detail: I already mitigated orphan Node processes with an external cleaner and launchd job. Even with orphan cleanup in place, high fan-out tool exploration still causes severe memory pressure episodes.
What Should Happen?
Memory should stay bounded during heavy exploration. If tool fan-out is high, the CLI should backpressure/schedule safely instead of causing system-level memory pressure.
Error Messages / Logs
No single fatal stack trace. The symptom is system memory pressure + swap growth.
Incident snapshots from this machine:
# During spike (2026-03-04)
memory_pressure -Q
System-wide memory free percentage: 39%
sysctl vm.swapusage
vm.swapusage: total = 29696.00M used = 28610.44M free = 1085.56M
vm_stat (excerpt)
Pages stored in compressor: 2157303
Swapouts: 10086565
# Another spike window
memory_pressure -Q
System-wide memory free percentage: 30%
vm_stat (excerpt)
Swapouts: 16568459
Pageouts: 511201
# Current environment check (after recovery)
claude --version
2.1.68 (Claude Code)
memory_pressure -Q
System-wide memory free percentage: 51%
sysctl vm.swapusage
vm.swapusage: total = 4096.00M used = 3311.62M free = 784.38M
Steps to Reproduce
- Start a fresh Claude Code session in a medium/large repo.
- Ask Claude to broadly explore architecture and related files (cross-folder, dependency tracing).
- Observe tool activity in that turn; in my case it often fans out to many calls (roughly 30+).
- Keep the session running while tool calls return.
- Memory pressure rises sharply and swap grows fast; terminal can become unresponsive.
Claude Model
Sonnet (default)
Is this a regression?
I don't know.
Last Working Version
Not sure. (I did not see this severity in an older npm-distributed setup, but I don't have an exact version number.)
Claude Code Version
2.1.68 (Claude Code)
Platform
Anthropic API / Claude subscription login (not Bedrock/Vertex)
Operating System
macOS (arm64)
- macOS 26.3 (Build 25D125)
- Hardware memory:
19327352832bytes (sysctl -n hw.memsize)
Terminal / Shell
- Ghostty (main)
- Also reproduced when using Terminal.app
- Shell: zsh
Additional Information
- Related issue: #20369 (orphaned subagent after terminal termination). My case is broader: high tool fan-out during active Explore turns, even after orphan mitigation.
- It would help a lot to have a CLI setting to cap concurrent tool calls (for example,
max_parallel_tool_calls). This would provide a practical safety valve for memory-constrained machines.
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗