Native memory leak causing extreme RAM consumption (534GB/hour growth rate)
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
What's Wrong?
Claude Code is experiencing a severe native memory leak that rapidly consumes all available system RAM.
System Info:
macOS
Claude Code version: 2.1.128
Memory Analysis:
After running /heapdump, the breakdown shows:
RSS: 0.40 GB (peak 0.40 GB)
JS heap: 0.07 GB
Array buffers: 0.01 GB
Other external: 0.04 GB
Unaccounted: 0.28 GB (code/JIT/stacks/allocator)
Growth rate: 534,250.6 MB/hour
Key Indicators:
⚠ Native memory > heap - leak may be in native addons (node-pty, sharp, etc.)
Most memory is native (NOT in the .heapsnapshot)
Process eventually consumes all system RAM and requires force termination
Memory not released by macOS even after process termination
Reproduction:
Memory usage grows continuously during normal Claude Code usage, eventually hitting system limits.
Files Attached:
.heapsnapshot file
Memory breakdown analysis
The leak appears to be in native addons rather than JavaScript objects, requiring investigation of components like node-pty or sharp.
What Should Happen?
After an hour of work its memory usage should not grow to 84Gb
Error Messages/Logs
Steps to Reproduce
Open 8-9 session, use MCP servers to browse own DOcker server pages, external pages, use hooks, use iTerm2 commands and soon memory grows.
Claude Model
Opus
Is this a regression?
Yes, this worked in a previous version
Last Working Version
2 versions ago
Claude Code Version
Version 1.6608.2 (ebf1a1)
Platform
Anthropic API
Operating System
macOS
Terminal/Shell
iTerm2
Additional Information
_No response_
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗