[BUG] Native memory leak — 1 GB RSS in 21 seconds (v2.1.71) [closed as duplicate]
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?
Native Memory Leak — Claude Code v2.1.71
Environment: macOS (darwin), Node v24.3.0, Claude Code 2.1.71
Trigger: manual heapdump after 21.0s uptime
Memory at dump time (~21s uptime)
| Metric | Value |
|--------|-------|
| RSS | 1038 MB |
| Heap Used | 123 MB |
| Heap Total | 50 MB |
| External | 81 MB |
| Array Buffers | 23 MB |
| Peak Malloc | 1038 MB |
| Growth Rate | 177837 MB/hour (~49 MB/s) |
Analysis
The JS heap is only ~123 MB but RSS is ~1038 MB after just 21 seconds of uptime. The vast majority of memory (~915 MB) is in native
allocations outside V8's control. The heapsnapshot confirms JS objects are not the source — top JS consumers are normal
(ArrayBuffers, code blocks, closures totaling ~70 MB).
Leak indicators flagged by diagnostics:
- Native memory > heap - leak may be in native addons (node-pty, sharp, etc.)
- High memory growth rate: 177836.7 MB/hour
This points to a native addon memory leak (likely node-pty or similar).
Attached files
- Diagnostics JSON
ba6f9371-88e6-40e6-940e-81a4dfb59bcb-diagnostics.json
)
What Should Happen?
Memory usage should remain stable and proportional to session activity. A fresh session with minimal interaction should not exceed
~200-300 MB RSS.
Error Messages/Logs
Steps to Reproduce
- Launch Claude Code (
claude) in a project directory - Send a short message (e.g. "hey")
- Run
/heapdumpafter ~20 seconds - Observe RSS at ~1 GB in the diagnostics JSON despite minimal activity
Claude Model
None
Is this a regression?
Yes, this worked in a previous version
Last Working Version
2.1.20
Claude Code Version
2.1.71
Platform
Anthropic API
Operating System
macOS
Terminal/Shell
Terminal.app (macOS)
Additional Information
_No response_
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗