Bug: Memory leak causing OOM kill on Linux (15-17GB memory consumption)

Resolved 💬 8 comments Opened Jan 28, 2026 by mookechee Closed Mar 15, 2026

Environment

  • Claude Code Version: 2.1.22
  • OS: Ubuntu 24.04.3 LTS (Noble Numbat)
  • Kernel: 6.14.0-37-generic
  • Node.js: v24.13.0
  • Hardware:
  • CPU: Intel i7-13700F (24 threads)
  • RAM: 32 GB DDR4 3200 MT/s
  • Motherboard: MSI PRO B760M-E DDR4

Configuration

  • Model: opus
  • Permissions mode: bypassPermissions
  • MCP Servers: 2 (HTTP type)
  • Enabled Plugins:
  • claude-code-wakatime@wakatime
  • rust-analyzer-lsp@claude-plugins-official
  • coderabbit@coderabbit

Description

Claude Code process is consuming excessive memory (15-17GB) and getting killed by Linux OOM killer. This has happened multiple times, with at least 2 documented occurrences in system logs. There are also earlier occurrences that were not captured in logs due to system reboots.

  1. Jan 24, 17:22 — claude process using 16.8 GB RAM was OOM-killed
  2. Jan 28, 14:55 — claude process using 15.1 GB RAM was OOM-killed

Reproduction Pattern

  • Usage frequency: Daily heavy use
  • Session duration before OOM: 30 minutes to 2 hours
  • Project size: Large codebases (>500 files)
  • Usage pattern:
  • Frequently using Task tool for parallel sub-agent execution
  • Running multiple Claude sessions concurrently in different terminal tabs (wezterm)
  • Mix of active monitoring and background running
  • Symptom before crash: Noticeable system slowdown before OOM kill

System Logs

OOM Event 1 (Jan 24, 17:22):

kernel: app invoked oom-killer: gfp_mask=0x140cca(GFP_HIGHUSER_MOVABLE|__GFP_COMP), order=0, oom_score_adj=300
kernel: Out of memory: Killed process 82624 (claude) total-vm:126107252kB, anon-rss:17638440kB, file-rss:0kB, shmem-rss:0kB, UID:1000 pgtables:45308kB oom_score_adj:200

OOM Event 2 (Jan 28, 14:55):

kernel: t:stork-22 invoked oom-killer: gfp_mask=0x140cca(GFP_HIGHUSER_MOVABLE|__GFP_COMP), order=0, oom_score_adj=200
kernel: Out of memory: Killed process 12883 (claude) total-vm:75770812kB, anon-rss:15868212kB, file-rss:308kB, shmem-rss:0kB, UID:1000 pgtables:39156kB oom_score_adj:100

Kernel memory state at OOM Event 2:

active_anon:4875734 inactive_anon:2811198 isolated_anon:0
active_file:17 inactive_file:1726 isolated_file:0
unevictable:223 dirty:0 writeback:0
slab_reclaimable:133416 slab_unreclaimable:126250
mapped:46961 shmem:20963 pagetables:47240
free:49846 free_pcp:0 free_cma:0
all_unreclaimable? yes

Key Observations

| Metric | Event 1 (Jan 24) | Event 2 (Jan 28) |
|--------|------------------|------------------|
| Killed process | claude (PID 82624) | claude (PID 12883) |
| Resident memory (anon-rss) | 16.8 GB | 15.1 GB |
| Virtual memory (total-vm) | 120 GB | 72 GB |
| Page tables | 44.2 MB | 38.2 MB |
| oom_score_adj | +200 | +100 |
| OOM trigger thread | (another app tried to allocate) | t:stork-22 (internal Claude thread) |

  • The t:stork-22 thread that triggered the second OOM appears to be an internal Claude Code worker thread.
  • Virtual memory requests (72-120 GB) are extremely high relative to physical RAM (32 GB).
  • Page table overhead (35-45 MB) suggests significant memory mapping activity.
  • System swap (8 GB) was also heavily utilized (~1.7 GB) before OOM.

Expected Behavior

Claude Code should not consume more than a reasonable amount of memory (perhaps 2-4 GB max) even during long sessions with parallel tasks on large codebases.

Possible Contributing Factors

  1. Multiple parallel Task sub-agents running simultaneously in large codebases
  2. Accumulated conversation context not being released
  3. MCP server connections maintaining state in memory
  4. Multiple concurrent Claude sessions amplifying the issue
  5. Possible memory leak in Node.js runtime during long-running sessions

View original on GitHub ↗

This issue has 8 comments on GitHub. Read the full discussion on GitHub ↗