[BUG] Runaway memory growth in Claude Code child process causes full system freeze (Ubuntu 24.04, requires hard reboot)
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
What's Wrong?
Environment
- OS: Ubuntu 24.04.4 LTS
- Kernel: 6.8.0-137-generic
- Claude Code version: 2.1.226 at session start, auto-updated to 2.1.232 during the session (confirmed via process snapshot, see below)
- Total RAM: 15.7 GB (no swap issue prior to incident, 2 GB swap configured)
Summary
A child process of Claude Code (not the main claude process itself) exhibits runaway memory growth, going from ~6.6 GB RSS to over 10.4 GB RSS in under 30 seconds while pegged at 90-100% CPU. This exhausts system RAM, pushes the system into heavy swap usage, and results in a complete system freeze requiring a hard reboot (REISUB) — not just a Claude Code crash.
This has happened on multiple occasions, including within the first ~20 minutes of a freshly started session, with no unusually large files or contexts involved.
Reproduction / monitoring setup
I built a custom monitoring script (plain-text logging, no ANSI, sampling every 2s, /proc/meminfo + ps based) that was running in a separate terminal at the time of the incident. It captured the full progression of the runaway process before the freeze made further logging impossible.
Timeline of the captured incident
| Time | Available RAM | Faulty process RSS | Faulty process %CPU | Faulty process %MEM |
|---|---|---|---|---|
| 10:47:37 | 8.3 GB (52%) | — | — | — |
| 10:48:39 | 3.2 GB (20%) | — | — | — |
| 10:48:43 | — | 6.6 GB | 100% | 41% |
| 10:48:53 | — | 8.2 GB | 93% | 51% |
| 10:49:04 | — | 9.6 GB | 90% | 60% |
| 10:49:10 | 92 MB (0%) | 10.4 GB | 91% | 65% |
At 10:49:10, available memory hit ~0%, swap usage reached 2 GB, and the monitoring log stops — consistent with the system freeze occurring at that point.
Key detail: the runaway process (PID 28089 in the capture) was a child of another process (PPID 28088), not the main Claude Code process itself (which stayed stable throughout at ~180-190 MB RSS, ~6% CPU). The child process's comm field in ps showed as 2.1.232 (the version string), suggesting it's spawned by the bun runtime Claude Code uses internally.
Evidence
Full monitoring log excerpt attached (claude_freeze_log_extrait.txt), covering the ~2 minutes leading up to the freeze, including per-process RSS/CPU snapshots at each alert threshold crossing.
What I was doing at the time
Web search and bash command.
Possible related issues
This looks related to existing reports of memory leaks / process explosion in the 2.1.x line:
- #20777 — Memory leak on Linux, RAM grows to 20GB+ causing system crash
- #21378 — Memory leak causes freeze after 20+ minutes (15GB RAM consumption)
- #23484 — Process explosion & resource exhaustion (Ubuntu 22.04, v2.1.30-2.1.32)
- #36022 — Claude Code causes system freeze on Ubuntu, requires hard restart
This report adds precise timing data (RSS growth rate: ~3.8 GB in under 30 seconds) and confirms the leak is in a child process, not the main Claude Code process, which may help narrow down the root cause.
Mitigation currently in place
Running Claude Code inside a memory-capped systemd user scope to convert freezes into recoverable OOM-kills:
systemd-run --user --scope -p MemoryMax=6G -p MemorySwapMax=512M claude
This works as a workaround but obviously isn't a fix for the underlying leak.
Request
- Is there a known root cause for child-process memory growth in this version range?
- Would full
/proc/<pid>/smapsor a core dump of the runaway child process be useful? Happy to capture one if this recurs (I now have automated monitoring in place that accelerates sampling to 1s on the first alert).
What Should Happen?
Claude should end the task without freezing
Error Messages/Logs
Steps to Reproduce
- Run
claude
Claude Model
Opus
Is this a regression?
I don't know
Last Working Version
_No response_
Claude Code Version
2.1.226
Platform
Anthropic API
Operating System
Ubuntu/Debian Linux
Terminal/Shell
Xterm
Additional Information
I know this bug has already been reported but the important thing is the monitoring log attached.
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗