Repository navigation
Description
Critical Memory Leak: Claude Code Consumed 129GB RAM and Caused System Freeze
Summary
Claude Code experienced a severe memory leak that consumed 129GB of virtual memory, exhausted all available system RAM (16GB), and caused a complete system freeze requiring a hard reboot.
Environment
- Claude Code Version: 2.0.36
- OS: Ubuntu 24.04.3 LTS
- Kernel: 6.14.0-35-generic
- Total RAM: 16GB
- CPU: 12 cores
- GPU: NVIDIA GeForce GTX 1070
Incident Details
Timeline (from sysstat data)
11:00:10 AM - Memory used: 11.17% (11 GB free)
11:10:08 AM - Memory used: 19.63% (8.5 GB free)
11:20:10 AM - Memory used: 55.87% (5.5 GB free) <- Rapid increase
11:30:10 AM - Memory used: 78.34% (1.1 GB free) <- Critical
11:33:16 AM - LINUX RESTART (complete system freeze)
Memory consumption increased from ~2GB to ~12GB in just 30 minutes, with no other resource-intensive applications running.
Process Memory Statistics (Post-Restart)
Name: claude
Pid: 3740
VmPeak: 135508316 kB (129 GB!)
VmSize: 75721528 kB (72 GB)
VmHWM: 569132 kB (556 MB peak resident)
VmRSS: 425416 kB (415 MB current resident)
VmData: 71003864 kB (68 GB data segment)
Threads: 19
Symptoms
- Gradual memory consumption over ~30 minutes
- Virtual memory peaked at 129GB (8x available physical RAM)
- System became completely unresponsive
- No kernel panic or OOM killer activation - just a hard freeze
- No swap usage (swap was at 0B throughout)
- Required hard power reset
System Logs
No warnings or errors before the freeze - the system just stopped logging at 11:31:19 AM. This indicates a complete kernel/hardware lockup due to memory exhaustion.
Last Activity Before Freeze
Nov 09 11:31:19 nick-System-Product-Name anacron[5742]: Normal exit (0 jobs run)
[No further logs until forced reboot at 11:33:16]
Expected Behavior
Claude Code should:
- Have reasonable memory bounds
- Implement memory management/garbage collection
- Not consume more than a few GB of RAM during normal operation
- Release memory when not actively processing
Actual Behavior
- Virtual memory ballooned to 129GB
- Physical memory consumption grew from ~2GB to ~12GB in 30 minutes
- System froze completely with no recovery possible
Reproduction
Unknown - this occurred during normal Claude Code usage. User reports this has happened multiple times.
Impact
- Severity: Critical
- Complete system lockup
- Data loss risk (requires hard reboot)
- System unusable until reboot
Additional Context
After reboot, the Claude Code process still shows 72GB virtual memory allocation, suggesting the leak condition persists and could recur at any time.
Suggested Investigation
- Memory profiling of the Claude Code process
- Check for circular references or unreleased resources
- Review context/conversation history storage (might be accumulating)
- Check if there's unbounded caching
- Review event listener cleanup
Workaround
Currently monitoring with: watch -n 1 'ps aux --sort=-%mem | head -5'
Plan to restart Claude Code when memory usage exceeds safe threshold.
Activity
mosabalhsseini commentedon Nov 16, 2025
Hello guys! Isn't there a permanent fix for this issue? Or a workaround?
chrismgonzalez commentedon Nov 21, 2025
I'm experiencing this as well.
Lincoln504 commentedon Nov 27, 2025
Also experiencing this, Debian 13. Same symptoms and issue as described in original post. Has happened to me 20+ times, and frequently happens when calling subtasks or when working with multiple CC agents at once.
isaaclyon commentedon Nov 30, 2025
Experiencing this as well. It's taking down other services on my Ubuntu server with 64gb of RAM.
timobehrens commentedon Dec 4, 2025
Same issue here. It usually happened when I restarted cursor with multiple windows of different projects opened, that had a claude session running. Seems claude tries to restore the session and then runs into a memory leak.
ShJavokhir commentedon Dec 4, 2025
This is critical bug. Just installing claude code with command
curl -fsSL https://claude.ai/install.sh | bashfroze entire ec2t3.smallinstance (aws linux OS). It's no longer accessible using ssh unless rebooted.tom-010 commentedon Dec 8, 2025
Same issue here with Version 2.0.61 (Claude Code), But it spiked to 11 GB, then dropped to 5 GB, then back to 200 MB (without any interaction) while normal usage (not installation)
smconner commentedon Dec 10, 2025
Critical Memory Leak in Claude Code - Comprehensive Analysis
Executive Summary
Claude Code has a severe memory management bug that causes each process to allocate 26-129GB of virtual memory regardless of actual usage. On systems with 16GB RAM, this leads to:
This bug has been documented since July 2025 and remains unfixed as of December 2025.
The Problem Visualized
Exposed Symptoms
Critical Discovery: The Rate Limit → Freeze Chain
The Trigger Sequence
Evidence from GitHub Issue #4580
Process sampling during freeze shows V8 stuck in JSON serialization:
Strace output reveals pathological memory behavior:
Why False Rate Limits Matter
The rate limit dialog (even when incorrect) triggers defensive state serialization - Claude tries to save your work before a potential interruption. If your conversation context:
...then
JSON.stringify()enters an infinite-like recursion, consuming CPU and thrashing memory.Warning Signs (Observed Pattern)
/rate-limit-optionsdialog appears unexpectedlyIf you see this pattern: immediately run
/clearor kill the session before it freezes.Reproduction Case Study
System: Ubuntu 24.04 LTS, 16GB RAM, 4GB swap, kernel 6.8.0-88-generic
Claude Code Version: 2.0.64
Workload: 11 concurrent Claude Code sessions (normal development workflow)
Memory State When Frozen
$ free -h total used free shared buff/cache available Mem: 15Gi 8.3Gi 2.5Gi 1.2Gi 5.1Gi 6.3Gi Swap: 4.0Gi 4.0Gi 7.1Mi # <-- 100% FULLProcess Analysis
The Smoking Gun
Each Claude process shows:
This is not normal. A healthy Node.js application should have VSZ:RSS ratios of 2-5:1, not 50:1.
Related GitHub Issues
--continue, 13GB swapPattern: Every issue involves massive virtual memory allocation disproportionate to actual usage.
New Pattern Identified: False rate limit → state serialization → JSON.stringify freeze → memory thrash → system lock.
Root Cause Analysis
Primary Issue: Unbounded Virtual Memory Reservation
Claude Code (or its dependencies) is calling
mmap()or equivalent with massive size requests without corresponding memory usage. This creates huge virtual address space reservations that:Likely Code Locations
Based on the symptoms, investigate these areas:
Evidence Supporting Each Theory
--max-old-space-sizeworkaround helpsWhat Needs to Be Fixed
For Anthropic Engineers
Immediate Architectural Recommendations
--max-old-space-sizeto CLI launcher - Simple, immediate impactReal Workarounds (Until Fixed)
These are actual technical mitigations, not "just restart constantly":
1. Limit Node.js Heap (Most Effective)
2. Install earlyoom (Prevents Hard Freeze)
3. Enable zswap (Compressed RAM-backed Swap)
4. cgroups Memory Limit (Hard Cap)
5. Increase OOM Priority (Die First, Save System)
6. Monitor and Auto-Kill Script
7. Malloc Tuning (Reduces Thrashing - from Issue #4580)
This reduces the 98% CPU spent on
munmapcalls but doesn't fix the root cause.8. Emergency Response: When Rate Limit Dialog Appears
If you see
/rate-limit-optionsand you're not near your limit:Recommended System Configuration
For systems running Claude Code regularly:
--max-old-space-size=4096Call to Action
For Anthropic:
For Users:
Appendix: Commands for Diagnosis
Report compiled: December 2025
Last updated: 2025-12-10
Environment: Ubuntu 24.04 LTS (kernel 6.8.0-88-generic), Claude Code v2.0.64
nklisch commentedon Jan 8, 2026
I started running out of diskspace as it filled it's virutal memory to 74gb per claude instance. this is clearly wrong.
41 remaining items
dom-cmyk commentedon May 4, 2026
This is becoming so annoying. Can't you ask your "famous" Mythos to fix this bug?
SevenSystems commentedon May 7, 2026
This happens to me even with a tiny conversation (~ 20 kB instructions in CLAUDE.md and ~ 20 mostly oneliner backs and forths). Claude Code, while sitting idle (!), allocating 50 MB/s of RAM.
RindraCoG commentedon May 8, 2026
I found temporary fix, disable claude self update, it occurs when claude update. at least using stable line for update
theQuert commentedon May 14, 2026
@/tmp/cc-reaper-comment-11315.md
ezin82 commentedon May 14, 2026
In my case, I discovered that the real problem was Claude Desktop. Preventing Claude Desktop from automatically starting at system startup solved the problem. It seems that Claude Desktop consumes memory even when not in use, remaining idle.
vphantom commentedon May 18, 2026
On Linux, look into setting up
earlyoom. It's been a life saver for me to prevent lock-ups. I have mine configured to keep at least 5% of RAM available and with its--preferand--avoidarguments it can be pretty friendly.SevenSystems commentedon May 19, 2026
@Ilya0527 the graphics driver angle is interesting -- that's what another LLM (Sonnet 4.6 -- not sure what you are) also suggested after showing it my journalctl output from right before the freeze. However, I'm on AMD and Radeon with the open-source drivers.
marcindulak commentedon May 19, 2026
I keep seeing large virtual memory size (#11315 (comment)) on an old Intel i5-6300U machine, with Intel integrated graphics. However, the resident memory usage appears lower since Claude version 2.1.1XX. The high resident memory usage behavior seems random (it always was random), now it does not even appear during Claude installation or update, so it's hard to make conclusions.
In the past OOM killer was not preventing a hard freeze of the machine, maybe the freeze was due to something else than memory? Therefore for the past several months I'm running Claude Code confined to a limited resource (16GB) virtual machine in Vagrant, to it freeze instead, and indeed every few days the machine is unrecoverable. Unfortunately, Vagrant itself is known for freezes, so again no conclusions, except the improvement that since February I had only one hard host system freeze.
SevenSystems commentedon May 19, 2026
I can confirm that I've seen much reduced resident memory usage too as of late 💐 I dug through the Claude Code changelog but couldn't spontaneously find a mention of memory-related fixes though.
marcindulak commentedon May 19, 2026
On the other hand, people report resident memory still growing with 2.1.143 #4953 (comment), and
claude updateitself being killed.marcindulak commentedon Jun 1, 2026
Another attempt (
2.1.159 (Claude Code)) at an installation ofcurl -fsSL https://claude.ai/install.sh | bashon a fresh virtual machine (nothing under~/.claude) still caused resident memory RES to grow to over 11GB and virtual machine to freeze (like in #11315 (comment)), but the host laptop did not freeze. Also linked here #4953 (comment).igor-vyatkin commentedon Jun 9, 2026
Same here,
claude --updateeats whole available memory during an update process. Update installed but memory usage is terrible.parth-io commentedon Jun 11, 2026
@SevenSystems
It was fixed in 2.1.160 according to the CHANGELOG.
I guess
claude --updatemessing up is a new bug.marcindulak commentedon Sep 19, 2026
The memory usage during Claude Code installation (install.sh on Linux) is now reduced #79421, but
2.1.274 (Claude Code)still keeps exhausting the available RAM (RSS) on a 12GB Linux virtual machine, causing an unrecoverable freeze, and sometimes, where other memory heavy programs are runnung, also manages to freeze the 32GB Linux laptop hosting the virtual machine.kgish commentedon Oct 12, 2026
I am still having this problem despite upgrading to the latest version.
Used the systemd-run workaround to prevent my whole system from going down, but still get regular crashes, often at the very end of a complex task right after it generares a markdown report of what has been done.