[BUG] Memory Leak: ArrayBuffer accumulation causing ~92 GB/hour growth (v2.1.71)

Resolved 💬 5 comments Opened Mar 10, 2026 by FrancoBertoldiMariglio Closed Apr 10, 2026

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 exhibits a severe memory leak caused by ArrayBuffer accumulation. The process grows from normal baseline to multiple GB within minutes, eventually causing system slowdown or freeze.

Claude Code exhibits a severe memory leak caused by ArrayBuffer accumulation. The process grows from normal baseline to multiple GB within minutes, eventually causing system slowdown or freeze.

Key Metrics from Diagnostics

{
  "memoryUsage": {
    "heapUsed": 3130281959,      // 3.13 GB
    "external": 3085226277,      // 3.08 GB (external to V8)
    "arrayBuffers": 2564982191,  // 2.56 GB ← PRIMARY CULPRIT
    "rss": 2560589824            // 2.56 GB resident
  },
  "memoryGrowthRate": {
    "bytesPerSecond": 26850805.95,
    "mbPerHour": 92184.92        // ~92 GB/hour growth rate
  },
  "uptimeSeconds": 95.36         // All this in < 2 minutes
}

Heap Snapshot Analysis

Captured via Chrome DevTools heap snapshot:

| Constructor | Instances | Shallow Size | Retained Size | % of Heap |
|-------------|-----------|--------------|---------------|-----------|
| ArrayBuffer | 9,710 | 2,561,231 kB | 2,561,233 kB | 85% |
| Uint8Array | 9,766 | 1,783 kB | 1,800 kB | 0% |
| Response | 4 | 378,813 kB | 378,814 kB | 13% |

Retainers analysis shows multiple (empty) in ArrayBuffer objects of exactly 262 kB each that are not being garbage collected. This pattern suggests:

  1. Streaming response chunks being retained
  2. File read buffers not released
  3. HTTP response bodies accumulating

V8 Heap Stats

{
  "heapSizeLimit": 17179869184,   // 16 GB limit
  "mallocedMemory": 3131331157,   // 3.13 GB malloc'd
  "peakMallocedMemory": 2560622592,
  "detachedContexts": 0,
  "nativeContexts": 1
}

What Should Happen?

Expected Behavior

Claude Code should maintain stable memory usage (~300-500 MB for typical sessions) and properly release ArrayBuffers after processing.

Actual Behavior

  • ArrayBuffers accumulate indefinitely (9,710+ instances observed)
  • Memory grows at ~26 MB/second (~92 GB/hour extrapolated)
  • No garbage collection of 262 kB buffer chunks
  • Process must be manually killed to recover memory

Error Messages/Logs

## Diagnostic Files

<details>
<summary>Full diagnostics.json</summary>


{
  "timestamp": "2026-03-10T14:57:37.382Z",
  "sessionId": "b95f7234-5723-45be-8705-ab8c0ec69716",
  "trigger": "manual",
  "dumpNumber": 0,
  "uptimeSeconds": 95.36361137499999,
  "memoryUsage": {
    "heapUsed": 3130281959,
    "heapTotal": 66146304,
    "external": 3085226277,
    "arrayBuffers": 2564982191,
    "rss": 2560589824
  },
  "memoryGrowthRate": {
    "bytesPerSecond": 26850805.952922106,
    "mbPerHour": 92184.92644359548
  },
  "v8HeapStats": {
    "heapSizeLimit": 17179869184,
    "mallocedMemory": 3131331157,
    "peakMallocedMemory": 2560622592,
    "detachedContexts": 0,
    "nativeContexts": 1
  },
  "resourceUsage": {
    "maxRSS": 2622094311424,
    "userCPUTime": 21209244,
    "systemCPUTime": 3392889
  },
  "activeHandles": 0,
  "activeRequests": 0,
  "analysis": {
    "potentialLeaks": [
      "High memory growth rate: 92184.9 MB/hour"
    ],
    "recommendation": "WARNING: 1 potential leak indicator(s) found. See potentialLeaks array."
  },
  "platform": "darwin",
  "nodeVersion": "v24.3.0",
  "ccVersion": "2.1.71"
}


</details>

## Heap Snapshot

Heap snapshot file available upon request (captured via `--inspect` flag and Chrome DevTools).

Steps to Reproduce

Steps to Reproduce

  1. Start Claude Code v2.1.71
  2. Run any prompt (or leave idle)
  3. Monitor memory with: watch -n 5 'ps aux --sort=-%mem | head -5'
  4. Observe memory growing continuously
  5. After ~2 minutes, memory exceeds 2.5+ GB
  6. System becomes unresponsive if not killed

Claude Model

Opus

Is this a regression?

Yes, this worked in a previous version

Last Working Version

2.1.16

Claude Code Version

2.1.17

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

Terminal.app (macOS)

Additional Information

Related Issues

This appears related to:

  • #22188 (93 GB heap allocation)
  • #18859 (idle session memory leak)
  • #27421 (memory leak + swap growth)
  • #4953 (120+ GB RAM, OOM killed)

View original on GitHub ↗

This issue has 5 comments on GitHub. Read the full discussion on GitHub ↗