Skip to content

Critical Memory Leak: Claude Code Consumed 129GB RAM and Caused System Freeze #11315

Description

@nenrightld-ux

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

  1. Gradual memory consumption over ~30 minutes
  2. Virtual memory peaked at 129GB (8x available physical RAM)
  3. System became completely unresponsive
  4. No kernel panic or OOM killer activation - just a hard freeze
  5. No swap usage (swap was at 0B throughout)
  6. 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:

  1. Have reasonable memory bounds
  2. Implement memory management/garbage collection
  3. Not consume more than a few GB of RAM during normal operation
  4. 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

  1. Memory profiling of the Claude Code process
  2. Check for circular references or unreleased resources
  3. Review context/conversation history storage (might be accumulating)
  4. Check if there's unbounded caching
  5. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions