[BUG] Memory leak: ArrayBuffers grow ~950 MB/hour, reaching 3.5 GB in 3h session
Note: This issue was filed by Claude Code (Opus 4.6) on behalf of the user, based on /heapdump diagnostics collected during the session.
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?
During a ~3.4 hour session with normal usage (file reads, edits, grep, git operations, subagent spawns), the CLI process memory grew to 4.25 GB. The vast majority sits in ArrayBuffers (3.5 GB), while the JS heap itself is only ~114 MB. Growth is linear at ~950 MB/hour.
This suggests HTTP response bodies or streamed API responses are being retained in native buffers and never garbage collected.
What Should Happen?
Memory usage should remain stable over long sessions. Response buffers should be freed after processing.
Error Messages/Logs
/heapdump diagnostics:
{
"uptimeSeconds": 12101,
"memoryUsage": {
"heapUsed": 4254996927,
"heapTotal": 113681408,
"external": 4174057200,
"arrayBuffers": 3508763148,
"rss": 3341729792
},
"memoryGrowthRate": {
"bytesPerSecond": 276152.30,
"mbPerHour": 948.09
},
"v8HeapStats": {
"heapSizeLimit": 36207493120,
"mallocedMemory": 4255259328,
"peakMallocedMemory": 3620749312
}
}
Key observations:
- JS heap (
heapTotal): ~114 MB — normal arrayBuffers: 3.5 GB — this is the leakexternal: 4.17 GB — confirms native buffer retention- Growth is linear at ~950 MB/hour
Steps to Reproduce
- Start a Claude Code session
- Use it normally for 2-3+ hours (file reads, edits, grep, git, subagent calls)
- Run
/heapdumpto capture diagnostics - Observe
arrayBuffersgrowing linearly with session duration
Claude Model
Opus
Is this a regression?
I don't know
Claude Code Version
2.1.72
Platform
Anthropic API
Operating System
macOS
Terminal/Shell
Ghostty with tmux
Additional Information
The heap snapshot (not attached due to privacy — contains conversation content, source code, and tokens in memory) shows the leak is entirely in ArrayBuffers / external memory, not in JS objects. The V8 heap is healthy at ~114 MB. This points to a buffer retention issue in the HTTP/streaming layer rather than a JS-level object leak.
This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗