Skip to content

Claude Code Memory Leak - Process Grows to 120+ GB RAM and Gets OOM Killed #4953

@chatgpt-copypasta

Description

@chatgpt-copypasta

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

  1. Start Claude Code in interactive mode
  2. Use it for an extended coding session (30-60 minutes)
  3. Perform typical operations: file reading, editing, searching, running bash commands
  4. Monitor memory usage with ps aux | grep claude
  5. 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:

  1. Causes system-wide memory exhaustion
  2. Triggers OOM killer which terminates other processes
  3. Loses session context when Claude is killed
  4. 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:

  1. Memory profiling of the claude process
  2. Heap snapshots at various points during execution
  3. 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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions