[BUG] Memory Leaks with Opus 4.6 CLI - massive sudden spikes in RAM/SWAP usage

Status Fixed / completed
Reported on v2.1.37
Maintainer reply None cached
Activity 7 comments · opened Feb 8, 2026 · closed Feb 20, 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?

Environment:

  • Claude Code (Max Plan)
  • Model: Opus 4.6 (did NOT experience this on Opus 4.5)
  • Platform: GCP VM, Ubuntu Linux, 15GB RAM, 16GB swap
  • VS Code SSH Remote for terminal access
  • Project type: Next.js

Frequency: 4 incidents in ~24 hours

Behavior:
Memory spikes suddenly (not gradual accumulation). Typical pattern:

  • Normal operation at ~1GB RAM per session with occasional small spikes
  • Issue simple command (e.g., "fix the font size on this badge")
  • RAM spikes to 6-14GB within 1 minute (yes within 1 minute, not a typo)
  • Status shows "0 tokens used"
  • No tool calls visible in output
  • Session appears to be "spinning" but never does anything
  • Happened within main session as well as subagent session

Recovery:

  • Pressing ESC immediately releases the memory IF caught as it's happening
  • If not caught in time, swap fills up and VM becomes unresponsive
  • First incident required a complete restart of the VM
  • Second incident I was able to slowly and painfully access browser-based SSH and kill the Claude PID hogging 25GB of RAM+SWAP
  • Third and fourth time I was able to hit ESC as it was happening after I installed a resource monitor

Possible trigger:
In one incident, the CC session self-diagnosed: "Yeah that was the system reminder trying to get me to use task
tools." The <system-reminder> about task tools may be triggering expensive processing.

Key observations:

  1. Spike happens BEFORE any action is actually taken by Claude Code (0 tokens)
  2. No tool calls executed — bug is in local preprocessing
  3. ESC releases memory instantly — suggests active allocation, not cached data
  4. Only happening on Opus 4.6, not 4.5
  5. All incidents on same Next.js project (not Python/Streamlit project on same VM, but I haven't tried Opus 4.6 on the python project yet)

Impact: VM crashes or becomes unresponsive if not caught quickly. Requires constant memory monitoring to use Claude Code reliably.

What Should Happen?

No good reason for Claude Code to hog 10GB+ RAM/SWAP within 1 minute without actually doing anything.

Error Messages/Logs

Steps to Reproduce

Unfortunately I can't replicate this on demand. It's happening randomly within a regular working session. This morning it happened after a fresh start (session had been compacted and restarted) on the second command.

Claude Model

Opus

Is this a regression?

Yes, this worked in a previous version

Last Working Version

_No response_

Claude Code Version

Version: 2.1.37

Platform

Anthropic API

Operating System

Ubuntu/Debian Linux

Terminal/Shell

VS Code integrated terminal

Additional Information

_No response_

View original on GitHub ↗

7 Comments

github-actions[bot] · 6 months ago

Found 3 possible duplicate issues:

  1. https://github.com/anthropics/claude-code/issues/23442
  2. https://github.com/anthropics/claude-code/issues/23484
  3. https://github.com/anthropics/claude-code/issues/21220

This issue will be automatically closed as a duplicate in 3 days.

  • If your issue is a duplicate, please close it and 👍 the existing issue instead
  • To prevent auto-closure, add a comment or 👎 this comment

🤖 Generated with Claude Code

nelisparts-code · 6 months ago

Reading through some of the other reported issues my gut is telling me there's a same underlying issue with Claude Code preprocessing causing massive memory leakage. While each environment is slightly different, and I'd say my environment has been the least heavy, the issues described are similar to mine. Sudden spikes in memory and swap usage during normal Claude Code CLI commands... Right now I have a resource monitor pinned just below my CLI session in VS Code so I keep an eye on it, but I'm afraid to step away for too long in case a memory spike happens again.

mintmcqueen · 6 months ago

Same. I remember using Claude squad back in June and noticing similar issues with parallel instances in tmux.

This version of Claude code is extremely sluggish.

ai-is-here · 6 months ago

I am on arch linux, and for the last week or a bit more, i now need to constantly look at ram and restart claudes in multiple terminals as they consistently grow to 10-20GBs.
Restarts help.
It worsens when claude runs bash/python scripts.
I am so tired at this point. Limits claude's autonomy to a huge degree.
And once it raises - it doesn't go back, no, it just stays and only climbs higher on each bash call.

<img width="1158" height="412" alt="Image" src="https://github.com/user-attachments/assets/8f4f00a6-c561-4d03-b6f0-abb34519d2cb" />

H1X4Dev · 6 months ago

Happens on windows too

Claude Code version: v2.1.38

<img width="803" height="141" alt="Image" src="https://github.com/user-attachments/assets/a1571dcb-90d4-49e1-83d6-ffca5436061b" />

nelisparts-code · 6 months ago

I got to say that the last few days have been much better. I'm on Version: 2.1.49 with Claude Code and haven't noticed any big memory jumps since around ~2.1.40 or so. Moreover, the accumulated memory consumption over a long session is much better too... still goes pretty high, but I can run a few claude code sessions and they USUALLY don't go over ~2-3GB, while in the past 10GB+ was common even without a sudden jump... So whatever Anthropic has been doing has helped for sure.

github-actions[bot] · 6 months ago

This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.