[BUG] Memory leak: ~46 GB of ArrayBuffers retained by unconsumed fetch Response bodies within seconds of startup

Resolved 💬 2 comments Opened Mar 12, 2026 by davis-allen-disney Closed Mar 12, 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?

Description

Claude Code accumulates tens of gigabytes of ArrayBuffers within seconds of startup due to fetch Response objects whose body chunks are never released. The v2.1.74 changelog mentions a fix for "streaming API response buffers were not released when the generator was terminated early, causing unbounded RSS growth on the Node.js/npm code path" — but the issue persists.

Environment

  • Claude Code version: 2.1.74
  • Platform: macOS (Darwin 25.2.0)
  • Node.js version: v24.3.0

Evidence

Heap snapshots were captured across four sessions at varying uptimes. All show the same pattern: thousands of uniformly-sized ArrayBuffers (~540 KB each) retained by 2 native::Response objects via a closure.

Dump summary

| | Dump 1 (5 min) | Dump 2 (37 min) | Dump 3 (3.8s) | Dump 4 (84s) |
|---|---|---|---|---|
| ArrayBuffer total | 1,171 MB | 909 MB | 865 MB | 46,724 MB |
| ArrayBuffer count | 2,215 | ~1,700 | 1,653 | 86,371 |
| Response size | 182 MB | 182 MB | 182 MB | 190 MB |
| Response count | 2 | 2 | 2 | 2 |

Worst case: Dump 4 (84 seconds uptime)

=== Top allocations by self size ===
46,724 MB (86,371)  ArrayBuffer
   190 MB (2)       Response
    10 MB (7)       Blob

Diagnostics JSON confirms:

  • memoryUsage.arrayBuffers: 46.7 GB
  • memoryUsage.rss: 1.95 GB
  • memoryGrowthRate: ~23 MB/sec (79,648 MB/hour)

ArrayBuffer size distribution (Dump 4)

| Range | Count |
|---|---|
| < 1 KB | 6 |
| 1–64 KB | 1 |
| 512 KB – 1 MB | 86,363 |
| > 10 MB | 1 (16.78 MB, likely WASM) |

99.99% of ArrayBuffers are uniformly sized at ~540 KB — consistent with streaming response body chunks.

Retainer chain

Response (190 MB)
  └── retained by IncomingMessage.FetchAPI
       └── retained by JSLexicalEnvironment (closure variable "response")

A closure holds a reference to the response variable, which retains the Response object and all of its streamed body chunks. The reference is never cleared, so none of the buffers can be GC'd.

The 2 Response objects are present in every dump regardless of uptime, suggesting they are allocated once at startup (likely an initial API call or bundle fetch) and never released.

What Should Happen?

Expected behavior

Streamed response body chunks should be released after consumption. The response closure variable should be cleared or allowed to go out of scope so the Response and its associated ArrayBuffers can be garbage collected.

Error Messages/Logs

Steps to Reproduce

Reproduction

  1. Start a fresh Claude Code session (v2.1.74)
  2. Take a heap snapshot within seconds (/heapdump)
  3. Observe hundreds of MB to tens of GB of ArrayBuffers retained by 2 Response objects via a closure

Claude Model

Opus

Is this a regression?

I don't know

Last Working Version

_No response_

Claude Code Version

2.1.74 (Claude Code)

Platform

AWS Bedrock

Operating System

macOS

Terminal/Shell

iTerm2

Additional Information

<img width="1776" height="900" alt="Image" src="https://github.com/user-attachments/assets/5469190a-47bb-45dd-8b9c-bb34c1dc2c68" />

View original on GitHub ↗

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