Claude Code Memory Leak - Process Grows to 120+ GB RAM and Gets OOM Killed
Claude Code Memory Leak - Process Grows to 120+ GB RAM and Gets OOM Killed
Description
Claude Code has a severe memory leak that causes the process to grow to over 120GB of RAM before being killed by the Linux OOM killer. This happens consistently during extended coding sessions, approximately every 30-60 minutes of active use.
Environment
- Claude Code Version: 1.0.53
- OS: Ubuntu 24.04
- Kernel: Linux 6.14.11
- Total System RAM: 128GB
- Installation Method: Direct installation in home directory
Steps to Reproduce
- Start Claude Code in interactive mode
- Use it for an extended coding session (30-60 minutes)
- Perform typical operations: file reading, editing, searching, running bash commands
- Monitor memory usage with
ps aux | grep claude - Process will gradually consume all available RAM until OOM killed
Expected Behavior
Claude Code should maintain stable memory usage throughout the session, not exceeding a reasonable amount (e.g., 1-2GB for typical usage).
Actual Behavior
The claude process memory usage grows unbounded until it consumes all available system RAM (120+ GB) and triggers the OOM killer.
Evidence
OOM Kill Log Entries (from dmesg):
Killed process 1983785 (claude) total-vm:234427056kB, anon-rss:124857720kB, file-rss:0kB, shmem-rss:0kB, UID:XXXX pgtables:267248kB oom_score_adj:0
Killed process 1991601 (claude) total-vm:234453364kB, anon-rss:125118596kB, file-rss:596kB, shmem-rss:0kB, UID:XXXX pgtables:267880kB oom_score_adj:0
Killed process 1997049 (claude) total-vm:234463420kB, anon-rss:125275392kB, file-rss:5856kB, shmem-rss:0kB, UID:XXXX pgtables:269168kB oom_score_adj:0
Killed process 2001723 (claude) total-vm:234420884kB, anon-rss:119597028kB, file-rss:3748kB, shmem-rss:0kB, UID:XXXX pgtables:257104kB oom_score_adj:0
Killed process 2009167 (claude) total-vm:234464008kB, anon-rss:120216960kB, file-rss:372kB, shmem-rss:0kB, UID:XXXX pgtables:252260kB oom_score_adj:0
Key observations:
- total-vm consistently around 234GB (virtual memory)
- anon-rss (actual RAM used) between 119-125GB
- Multiple OOM kills in the same session indicate this is a recurring issue
- Memory consumption appears to be primarily anonymous pages (anon-rss), not file-backed
Impact
This memory leak makes Claude Code unusable for extended coding sessions as it:
- Causes system-wide memory exhaustion
- Triggers OOM killer which terminates other processes
- Loses session context when Claude is killed
- Requires frequent restarts, disrupting workflow
Additional Information
- The memory growth appears gradual over time, not sudden
- The issue persists across multiple sessions
- After OOM kill and restart, memory usage starts low (~400MB) and grows again
Potential Debugging Steps
To help diagnose this issue, the following information might be useful:
- Memory profiling of the claude process
- Heap snapshots at various points during execution
- Tracking of any unbounded data structures (conversation history, file caches, etc.)
Workaround
Currently, the only workaround is to periodically restart Claude Code before memory exhaustion occurs, which is highly disruptive to workflow.
Priority: High - This makes the tool unusable for its intended purpose of extended coding assistance
Found 3 possible duplicate issues:
- https://github.com/anthropics/claude-code/issues/3643
- https://github.com/anthropics/claude-code/issues/1009
- https://github.com/anthropics/claude-code/issues/2938
If your issue is a duplicate, please close it and 👍 the existing issue instead.
🤖 Generated with Claude Code
does this was fixed? seems to be i had that too once, the IDE showed the notification e.g. out of memory.
I'm still having this issue regardless of where I run it. It's making CC hard to use, as it crashes machine after a while
I've been having this since I started using subagents (since version ~1.0.70). Can't use more than 2 Claude Code instances because I ONLY have 32 GB of RAM.
me too..
I've solevd this by commiting to memory that CC should terminate any processes it's done using. I have stopped having issues.
I've solevd this by commiting to memory that CC should terminate any processes it's done using. I have stopped having issues.
thanks, bro. Can you explain more? Do you use CC hooks?
I am still seeing this on 1.0.98 where I've got 4 processes each taking about 2.5GB RAM
Environment
- Claude Code Version: 2.0.1 (Claude Code)
- Claude Model: claude-sonnet-4-5-20250929
- Platform: Linux 6.14.0-15-generic
- RAM: 15GB
- Swap: None
Issue Description
Claude Code process experiencing rapid memory growth leading to OOM kills. Monitoring shows memory jumps from stable baseline to crash threshold within minutes.
Memory Growth Pattern (from monitoring)
2025-10-11 18:46:48 PID:3174091 RSS:204MB VSZ:32120MB ← stable 2025-10-11 18:47:48 PID:3174091 RSS:1554MB VSZ:33467MB ← 7x jump in 60s 2025-10-11 18:48:48 PID:3174091 RSS:3967MB VSZ:35869MB ← nearly doubled 2025-10-11 18:49:48 PID:3174091 RSS:4301MB VSZ:36201MB ← crash threshold [Process killed by OOM]
Historical OOM Kills
10+ kills over 2 days (Oct 3-5):
- Processes growing from 1.3GB → 4.3GB RSS before kill
- Virtual memory: 33GB → 37GB range
Sample kern.log Entry
2025-10-05T14:12:52 kernel: Out of memory: Killed process 1418229 (claude) total-vm:36857676kB, anon-rss:4102880kB, file-rss:3048kB, shmem-rss:0kB, UID:1001 pgtables:119712kB oom_score_adj:0
Impact
System unusable for extended Claude Code sessions. Process requires restart every 30-60 minutes to prevent OOM.
Monitoring Setup
Created automated monitoring script logging memory every 60s to track growth patterns.
I got a record 34 GB yesterday on my Mac M1 Max 32 GB!
97gb here :)
on v2.0.27
Yesterday my claude instance got up to 107GB after a few hours of very intensive work and took down my whole machine.
Consistently getting 130GB+
and sometimes VS Code just crashes UI
Only 2 VS Code windows are running simultaneously...
UPD. I think it was audio and ntfy hooks (asked CC to optimize them and remove ntfy)
Related?
My CC shows that on every startup right away
This issue has been inactive for 30 days. If the issue is still occurring, please comment to let us know. Otherwise, this issue will be automatically closed in 30 days for housekeeping purposes.
up
Here because i've seen it 128GB RAM and recently started getting "Your system has run out of application memory" -- it's claude code. 120GB+ !!
On Mac it spins up dozens and dozens of claude instances each with ~250mb memory usage. I'm using the VS Code extension, and it seems to partially help to close tabs and re-open them, but only partially. It's really really annoying and leads to the system eventually filling swap to the point it's unusable and I have to reboot.