[BUG] Unbounded session file growth from verbose command output causes 100% CPU + OOM crash on ANY session start
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?
Session history .jsonl files grow unbounded when Claude Code captures verbose command output. On subsequent startup or /resume, Claude Code loads the entire session file into memory, causing 80GB+ VIRT allocation and OOM crashes. In my case, a 3.6GB session file from captured e2fsck output crashed WSL2 repeatedly.
The corrupted/oversized session file affects ALL Claude Code instances, not just when resuming that specific session. Simply having a large .jsonl file in ~/.claude/projects/ causes:
- 100% CPU usage on single core (apparent infinite loop during startup)
- 80GB+ VIRT memory allocation
- OOM crash / WSL2 E_UNEXPECTED crash
This suggests Claude Code reads/processes ALL session files at startup, not just the active one.
What Should Happen?
Command output in session history should be truncated (e.g., cap at 100KB per command). Session files should have size limits. Large sessions should fail gracefully with a warning instead of OOM. Startup should not eagerly load multi-GB history into memory.
Error Messages/Logs
WSL2: Wsl/Service/E_UNEXPECTED
[process exited with code 4294967295 (0xffffffff)]
htop showed: VIRT 80.2G, MEM% 92.6, multiple claude processes
Offending file: 3.6GB single .jsonl
find ~/.claude/projects -type f -size +50M
/home/user/.claude/projects/-home-user/9f99474b-xxxx.jsonl (3.6GB)
Steps to Reproduce
- Start Claude Code session in any directory
- SSH to remote server and run command with massive output (e.g.,
e2fsck -von filesystem with many errors, orcata huge log file) - Let session save automatically
- Exit Claude Code
- Start Claude Code again in same directory or use
/resume - Observe extreme memory consumption and crash/hang
Claude Model
Opus
Is this a regression?
I don't know
Last Working Version
_No response_
Claude Code Version
2.1.19
Platform
Anthropic API
Operating System
Ubuntu/Debian Linux
Terminal/Shell
WSL (Windows Subsystem for Linux)
Additional Information
Workaround: Delete oversized session files manually:
rm ~/.claude/projects/[project-dir]/[oversized-file].jsonl
The root cause is no size limit on captured command output in session history. Running 20+ concurrent Claude instances worked fine until one session captured verbose e2fsck output, creating the 3.6GB file.
Environment: WSL2 Ubuntu 24.04, 16GB RAM (7GB to WSL), Node v20.19.5
Related issues (but distinct behavior):
- #3178 - OOM on --resume (our bug affects fresh sessions too)
- #8722 - Accumulated history OOM (our bug is single 3.6GB file from command output)
This issue has 5 comments on GitHub. Read the full discussion on GitHub ↗