Memory leak: 14K ArrayBuffers accumulate from streaming responses (~480 MB/hour)

Resolved 💬 4 comments Opened Mar 10, 2026 by kevin-tcircuits Closed Apr 10, 2026

Description

Claude Code accumulates ArrayBuffer objects over time, leading to significant memory growth. After ~14.5 hours of uptime, the process consumed ~7 GB of RAM with a steady growth rate of ~480 MB/hour.

Environment

  • Claude Code version: 2.1.71
  • Node.js: v24.3.0
  • Platform: Linux (Ubuntu 22.04, WSL2, x86_64)

Heap Dump Analysis

Captured a V8 heap snapshot (/heapdump) and diagnostics JSON. Key findings:

Memory Breakdown

| Metric | Value |
|--------|-------|
| RSS | 6.9 GB |
| V8 Heap (JS objects) | 70 MB |
| External/Native memory | 7.56 GB |
| ArrayBuffers | 6.83 GB |
| Growth rate | 478.6 MB/hour |
| Uptime at capture | ~14.5 hours |

Heap Snapshot Object Breakdown

| Object Type | Count | Aggregate Size |
|-------------|-------|----------------|
| ArrayBuffer | 14,002 | 6,512 MB |
| Response (native HTTP) | 2 | 446 MB |
| Uint8Array (views) | 14,228 | ~2 MB (metadata) |
| Blob (native) | ~5 | ~7 MB |
| All other JS objects | ~640K | ~57 MB |

The V8 JS heap itself is tiny (70 MB). Nearly all memory is in external/native allocations backing ArrayBuffer objects.

Pattern

  • ~14,000 ArrayBuffers, mostly 0.5 MB each, with a few at 16-32 MB
  • Two retained native Response objects at 223 MB each (HTTP API responses)
  • 14,228 Uint8Array views corresponding to the ArrayBuffers
  • Growth rate of ~16 new 0.5 MB buffers per minute, consistent with streaming API token delivery

Diagnostics JSON Summary

{
  "memoryUsage": {
    "heapUsed": 7613741617,
    "heapTotal": 70292480,
    "external": 7562328657,
    "arrayBuffers": 6829807179,
    "rss": 7256211456
  },
  "memoryGrowthRate": {
    "bytesPerSecond": 139398.6,
    "mbPerHour": 478.6
  },
  "analysis": {
    "potentialLeaks": ["High memory growth rate: 478.6 MB/hour"]
  }
}

Likely Cause

Streaming API response chunks (ArrayBuffers) and/or their backing native Response objects are not being released after consumption. The steady linear growth rate and uniform ~0.5 MB buffer size point to per-chunk allocations from the Anthropic API streaming responses that are retained indefinitely.

Workaround

Restart Claude Code periodically (every few hours) to reclaim memory.

View original on GitHub ↗

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