Memory leak: Claude Code process grows to 93 GB heap allocation
Description
Claude Code processes can exhibit severe memory leaks, with heap allocations growing to 93 GB and RSS memory usage reaching 16+ GB. This causes system-wide slowness due to swap thrashing.
Environment
- Claude Code version: 2.1.27
- OS: Ubuntu Linux (kernel 6.14.0-37-generic)
- System RAM: 32 GB
- Plugins enabled:
context7@claude-plugins-officialsuperpowers@claude-plugins-officialbasedpyright-lsp@flaks-claude-code-plugins
Observed Behavior
A Claude Code process running in a project directory accumulated extreme memory usage:
PID 2916059:
- VmPeak: 135,528,076 kB (135 GB virtual peak)
- VmSize: 99,033,756 kB (99 GB virtual)
- VmRSS: 8,561,792 kB (8.5 GB resident) - was 16.7 GB earlier
- VmData: 93,042,656 kB (93 GB heap allocation)
- VmSwap: 274,948 kB
The process was started with claude --dangerously-skip-permissions and had been running for approximately 5 minutes when measured. Only a single prompt had been run: /resume. This command has been running for > 10 minutes using 100% of a cpu core all the time until I killed it.
Impact
kswapd0(kernel swap daemon) at 100% CPU due to memory pressure- 21 GB swap usage on a 32 GB RAM system
- System became very slow;
/resumecommand took >60 seconds - Other Claude Code instances also affected by system resource exhaustion
Process Tree
The affected process had spawned:
basedpyright-langserver(Python LSP via plugin)npm exec @upstash/context7-mcp(Context7 MCP server via plugin)
Project Details
- Project size: 496 MB
- File count: 15,371 files (7,006 Python files) (this includes a Python .venv folder)
- Session file size: ~3.5 MB
Additional Context
- Multiple Claude Code instances were running concurrently (4 total)
- One other instance had been running for 140 minutes at 60% CPU, but it was running long agent sessions
- The default Node.js V8 heap limit is ~4 GB, but this process far exceeded that
Expected Behavior
Claude Code should not allocate 93 GB of heap memory. Memory usage should remain bounded and reasonable for the project size and session history.
Steps to Reproduce
Unable to provide exact reproduction steps as this appeared to occur during normal usage.
This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗