Description
Claude Code CLI process exhibits aggressive memory growth (~18 GB/hour), reaching ~2 GB RSS in under 7 minutes. The diagnostics indicate the leak is in native memory (outside V8 heap), likely in native addons such as node-pty.
Diagnostics (/heapdump output)
{
"trigger": "manual",
"uptimeSeconds": 404,
"memoryUsage": {
"heapUsed": 197405793,
"heapTotal": 71928832,
"external": 151865422,
"arrayBuffers": 54231508,
"rss": 2142371840
},
"memoryGrowthRate": {
"bytesPerSecond": 5301361,
"mbPerHour": 18200
},
"v8HeapStats": {
"heapSizeLimit": 26947584000,
"mallocedMemory": 197668190,
"peakMallocedMemory": 2694758400
},
"analysis": {
"potentialLeaks": [
"Native memory > heap - leak may be in native addons (node-pty, sharp, etc.)",
"High memory growth rate: 18200.8 MB/hour"
]
},
"platform": "darwin",
"nodeVersion": "v24.3.0",
"ccVersion": "2.1.71"
}
Key observations
- JS heap is only ~188 MB, but RSS is ~2 GB — the gap is in native/external memory
external memory (151 MB) and arrayBuffers (52 MB) suggest buffer accumulation
peakMallocedMemory (2.7 GB) vs current mallocedMemory (197 MB) shows large allocations happened and were freed, but RSS wasn't returned to OS
- Growth rate of ~5.3 MB/s is unsustainable for long sessions
Environment
- macOS (Darwin)
- Node.js v24.3.0
- Claude Code v2.1.71
Description
Claude Code CLI process exhibits aggressive memory growth (~18 GB/hour), reaching ~2 GB RSS in under 7 minutes. The diagnostics indicate the leak is in native memory (outside V8 heap), likely in native addons such as
node-pty.Diagnostics (
/heapdumpoutput){ "trigger": "manual", "uptimeSeconds": 404, "memoryUsage": { "heapUsed": 197405793, "heapTotal": 71928832, "external": 151865422, "arrayBuffers": 54231508, "rss": 2142371840 }, "memoryGrowthRate": { "bytesPerSecond": 5301361, "mbPerHour": 18200 }, "v8HeapStats": { "heapSizeLimit": 26947584000, "mallocedMemory": 197668190, "peakMallocedMemory": 2694758400 }, "analysis": { "potentialLeaks": [ "Native memory > heap - leak may be in native addons (node-pty, sharp, etc.)", "High memory growth rate: 18200.8 MB/hour" ] }, "platform": "darwin", "nodeVersion": "v24.3.0", "ccVersion": "2.1.71" }Key observations
externalmemory (151 MB) andarrayBuffers(52 MB) suggest buffer accumulationpeakMallocedMemory(2.7 GB) vs currentmallocedMemory(197 MB) shows large allocations happened and were freed, but RSS wasn't returned to OSEnvironment