Memory leak in active sessions with many skills (23GB+ RAM after 30min)
Environment
- Claude Code version: 2.1.29
- OS: macOS Darwin 23.6.0
- RAM: 64GB
- Number of skills/commands: 1,071 files (16MB in
.claude/commands/)
Problem
Active Claude Code sessions accumulate massive amounts of memory over time, while abandoned sessions remain at normal levels.
Observed behavior:
| Session PID | PPID | Status | Elapsed Time | RAM Usage |
|-------------|------|--------|--------------|-----------|
| 16393 | 1 (orphan) | Abandoned | 40 min | 145MB ✅ |
| 36415 | 1 (orphan) | Abandoned | 15 min | 148MB ✅ |
| 39581 | 1 (orphan) | Abandoned | 11 min | 146MB ✅ |
| 22728 | terminal | Active | 30 min | 23GB ⚠️ |
| 25636 | terminal | Active | 28 min | 18GB ⚠️ |
Key observations:
- Normal sessions use ~150MB - Orphaned/abandoned sessions maintain reasonable memory usage
- Active sessions explode to 23GB+ - Sessions being actively used accumulate memory without bound
- Pattern is reproducible - Multiple active sessions show the same behavior
- File descriptors also high - Heavy processes had 1,500-1,700+ open file descriptors
Reproduction context
- Project has 1,071 skill files in
.claude/commands/ - Custom hooks configured in
.claude/hooks/ - Using Context7 MCP server (but MCP processes themselves use minimal RAM ~30-77MB)
- System reports 98% RAM used, but
memory_pressureshows 78% free (macOS memory compression working overtime)
Expected behavior
Sessions should maintain reasonable memory usage (~150-500MB) regardless of activity level, similar to abandoned sessions.
Impact
- System becomes unresponsive during Bash tool operations
- Forces users to restart sessions frequently
- Makes Claude Code unusable on machines with 8-16GB RAM if they have many skills
Additional data
$ memory_pressure
Pages used by compressor: 689819
Pages decompressed: 1185207
Pages compressed: 2339114
The high compressor activity suggests the system is struggling to manage the memory leak.
This issue has 8 comments on GitHub. Read the full discussion on GitHub ↗