Memory leak: 4.2 GB RSS after 3.5 minutes, native memory dominates V8 heap
Environment
- Claude Code version: 2.1.73
- Node.js version: v24.3.0
- Platform: macOS (Darwin 25.4.0)
- Runtime: Bun
Summary
Claude Code reaches 4.2 GB RSS within ~3.5 minutes of operation. Heap snapshot and diagnostics analysis shows the vast majority of memory lives outside the V8 heap in native allocations, with a growth rate of ~67 GB/hour.
Diagnostics
{
"uptimeSeconds": 215.75,
"memoryUsage": {
"heapUsed": 327947696,
"heapTotal": 57911296,
"external": 279725056,
"arrayBuffers": 25776982,
"rss": 4221992960
},
"memoryGrowthRate": {
"bytesPerSecond": 19568484,
"mbPerHour": 67183
},
"v8HeapStats": {
"mallocedMemory": 328215984,
"peakMallocedMemory": 4222025728
}
}
Heap Snapshot Analysis
V8 heap accounts for ~485 MB total. RSS is 4.2 GB. That leaves ~3.7 GB in native allocations outside the V8 heap.
Largest JS-visible objects by self size
| Object | Self Size | Count |
|---|---|---|
| BytesInternalReadableStreamSource | 231 MB | 3 |
| Response (native) | 182 MB | 2 |
| ArrayBuffer | 16 MB | 9 |
| Blob (native) | 10 MB | 7 |
Aggregate by node type
| Type | Count | Self Size |
|---|---|---|
| object | 54,597 | 251 MB |
| native | 147 | 191 MB |
| code | 123,929 | 25 MB |
| closure | 148,008 | 5 MB |
| string | 80,710 | 4 MB |
Analysis
- Unreleased HTTP Response streams: Three
BytesInternalReadableStreamSourceobjects (231 MB) and twoResponseobjects (182 MB) dominate the JS heap. These appear to be API response bodies that are not being fully consumed or closed, keeping large native buffers alive.
- Native memory leak: The gap between V8 heap (~485 MB) and RSS (4.2 GB) indicates ~3.7 GB of native memory. The diagnostics correctly identifies: _"Native memory > heap - leak may be in native addons (node-pty, sharp, etc.)"_. Likely culprits are node-pty (terminal multiplexing) and/or Bun's internal HTTP client / TLS buffers.
- Growth rate: At ~67 GB/hour, the process will exhaust available memory quickly on machines with limited RAM.
maxRSSreporting bug:resourceUsage.maxRSSreports ~4.3 TB which appears to be a reporting bug (possibly in Node v24.3.0 or Bun'sprocess.resourceUsage()implementation).
Steps to Reproduce
- Start a Claude Code session
- Use it normally for a few minutes
- Run
/heapdump - Observe RSS in diagnostics JSON
Expected Behavior
RSS should remain proportional to actual work being done, not grow at 67 GB/hour. HTTP Response bodies from API calls should be fully consumed and released.
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗