[BUG] High memory consumption when CC is auto-downloading a new version of itself
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?
I launched Claude Code in the directory of a small existing project. It almost immediately said it was using a lot of memory, and recommended I do /heapdump.
Here is the JSON diagnostics file:
7dad8859-56ac-4b37-930d-04e0f9dc7212-diagnostics.json
I asked CC to analyze the heap dump. Here is what it said:
== begin ==
⏺ Here's the picture. The key finding is in that URL:
https://storage.googleapis.com/claude-code-dist-.../claude-code-releases/2.1.74/darwin-arm64/claude
Claude Code is downloading a self-update binary — the full claude native binary for darwin-arm64. The 181 MB Response object is holding
that HTTP response, and the body is being buffered into 4,880 x 512 KB ArrayBuffers (totaling ~2.44 GB) plus 124 x 256 KB buffers (~31
MB).
Here's the breakdown:
┌─────────────────────────────┬───────────┐
│ What │ Size │
├─────────────────────────────┼───────────┤
│ ArrayBuffers (512KB x 4880) │ ~2,441 MB │
├─────────────────────────────┼───────────┤
│ ArrayBuffers (256KB x 124) │ ~31 MB │
├─────────────────────────────┼───────────┤
│ Response object (native) │ ~182 MB │
├─────────────────────────────┼───────────┤
│ Total │ ~2.7 GB │
└─────────────────────────────┴───────────┘
What happened: Within the first 28 seconds of startup, Claude Code v2.1.73 detected that v2.1.74 was available and began fetching the
update binary. The response body stream is being consumed but the data is accumulating in memory — the ReadableStream body is being
buffered rather than streamed to disk. At the observed growth rate of ~70 GB/hour (~20 MB/s), it was filling up memory fast enough to
trigger the high-memory warning.
In short: This is a bug in Claude Code's auto-update mechanism. The update download is buffering the entire binary into heap memory (as
thousands of 512KB ArrayBuffers) instead of streaming it directly to disk. For a large native binary, this blows up memory usage almost
immediately. This is a Claude Code bug, not something in your project.
== end ==
It also summarized: "The key finding: the update download URL (claude-code-releases/2.1.74/darwin-arm64/claude) buffering into ~4,880 x 512KB ArrayBuffers"
What Should Happen?
Should not use excess memory when self-updating
Error Messages/Logs
Steps to Reproduce
Not reproducible
Claude Model
Opus
Is this a regression?
Yes, this worked in a previous version
Last Working Version
_No response_
Claude Code Version
2.1.73
Platform
Anthropic API
Operating System
macOS
Terminal/Shell
iTerm2
Additional Information
_No response_
This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗