[BUG] Memory leak: ArrayBuffers grow ~950 MB/hour, reaching 3.5 GB in 3h session

Resolved 💬 4 comments Opened Mar 12, 2026 by Afik-BenShi Closed Apr 9, 2026
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 leak
  • external: 4.17 GB — confirms native buffer retention
  • Growth is linear at ~950 MB/hour

Steps to Reproduce

  1. Start a Claude Code session
  2. Use it normally for 2-3+ hours (file reads, edits, grep, git, subagent calls)
  3. Run /heapdump to capture diagnostics
  4. Observe arrayBuffers growing 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.

View original on GitHub ↗

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