Skip to content

[BUG] Unbounded session file growth from verbose command output causes 100% CPU + OOM crash on ANY session start #21179

Closed as not planned

Description

@MagnaCapax

Preflight Checklist

  • I have searched existing issues and this hasn't been reported yet
  • This is a single bug report (please file separate reports for different bugs)
  • 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

  1. Start Claude Code session in any directory
  2. SSH to remote server and run command with massive output (e.g., e2fsck -v on filesystem with many errors, or cat a huge log file)
  3. Let session save automatically
  4. Exit Claude Code
  5. Start Claude Code again in same directory or use /resume
  6. 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):

Activity

  1. dehengxu commented on Jan 27, 2026

    @dehengxu

    Same with you, and older version also hang and consume huge memory finally killed by sys

  2. QuintinWillison commented on Jan 27, 2026

    @QuintinWillison

    I am genuinely confused as to what I just experienced. I used Claude (Web) to attempt to debug, and in the process it looks like a version 2.1.20 release slipped in which fixes this! I had watched Claude Code get Killed for OOM (using watch -n 0.5 'free -h; echo; ps aux --sort=-%mem | head -5' in a discrete terminal session) and had even increased my Lima-provided Ubuntu VM that hosts Claude Code from 2GB to 4GB memory in case that might help. Only thing I might have done yesterday as a "mistake" was take Claude Code's warning/yellow instruction text at its word and run claude install. My Terminal right now 🤯:

    lima@lima-claude:/Users/Quintinwillison/code/CPC-Systems/Platform1-ROC$ which claude
    /home/lima.linux/.local/bin/claude
    lima@lima-claude:/Users/Quintinwillison/code/CPC-Systems/Platform1-ROC$ claude uninstall
                                                                                                                                                            
    ╭─── Claude Code v2.1.19 ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
    │                                                     │ Tips for getting started                                                                       │
    │                   Welcome back Q!                   │ Run /init to create a CLAUDE.md file with instructions for Claude                              │
    │                                                     │                                                                                                │
    │                                                     │ ─────────────────────────────────────────────────────────────────                              │
    │                       ▐▛███▜▌                       │ Recent activity                                                                                │
    │                      ▝▜█████▛▘                      │ No recent activity                                                                             │
    │                        ▘▘ ▝▝                        │                                                                                                │
    │  Sonnet 4.5 · Claude Max · quintin@zzz's            │                                                                                                │
    │  Organization                                       │                                                                                                │
    │  /…/Quintinwillison/code/CPC-Systems/Platform1-ROC  │                                                                                                │
    ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
                                                                                                                                                            
    ❯ uninstall                                                                                                                                             
                                                                                                                                                            
    ● I need to clarify what you'd like to uninstall. Could you provide more details?                                                                       
                                                                                                                                                            
    ● User answered Claude's questions:                                                                                                                     
      ⎿  · What would you like to uninstall? → Claude Code                                                                                                  
                                                                                                                                                            
    ● To uninstall Claude Code, the method depends on how it was installed:                                                                                 
                                                                                                                                                            
      If installed via npm (global):                                                                                                                        
      npm uninstall -g @anthropic-ai/claude-code                                                                                                            
                                                                                                                                                            
      If installed via Homebrew (macOS):                                                                                                                    
      brew uninstall claude-code                                                                                                                            
                                                                                                                                                            
      To also remove configuration files and cache:                                                                                                         
      rm -rf ~/.claude                                                                                                                                      
                                                                                                                                                            
      Since you mentioned you're running in a Lima Ubuntu instance, it was likely installed via npm. Run the npm uninstall command above.                   
                                                                                                                                                            
      Is there anything specific prompting this, or would you like help with anything else before uninstalling?                                             
                                                                                                                                                            
    ❯ A major BUG in version 2.1.19 that causes the process to immediately be Killed due to OOM so I need to downgrade to npm-provided 2.1.18               
                                                                                                                                                            
    ● To downgrade to version 2.1.18:                                                                                                                       
                                                                                                                                                            
      npm uninstall -g @anthropic-ai/claude-code && npm install -g @anthropic-ai/claude-code@2.1.18                                                         
                                                                                                                                                            
      This will remove 2.1.19 and install 2.1.18 in one command. After running it, verify with claude --version.                                            
                                                                                                                                                            
    ❯ /exit                                                                                                                                                 
      ⎿  Catch you later!                                                                                                                                   
                                                                                                                                                            
    ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
    ❯                                                                                                                                                       
    ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
      ⏸ plan mode on (shift+Tab to cycle)                                                                                             Checking for updates  
    lima@lima-claude:/Users/Quintinwillison/code/CPC-Systems/Platform1-ROC$ npm uninstall -g @anthropic-ai/claude-code && npm install -g @anthropic-ai/claude-code@2.1.18                                                                                                                                           
                                                                                                                                                            
    up to date in 193ms
    
    added 3 packages in 3s
    
    2 packages are looking for funding
      run `npm fund` for details
    lima@lima-claude:/Users/Quintinwillison/code/CPC-Systems/Platform1-ROC$ claude --version
    2.1.20 (Claude Code)
    lima@lima-claude:/Users/Quintinwillison/code/CPC-Systems/Platform1-ROC$ claude
                                                                                                                                                            
    ╭─── Claude Code v2.1.20 ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
    │                                                    │ Tips for getting started                                                                        │
    │                   Welcome back Q!                  │ Run /init to create a CLAUDE.md file with instructions for Claude                               │
    │                                                    │ ─────────────────────────────────────────────────────────────────                               │
    │                                                    │ Recent activity                                                                                 │
    │                       ▐▛███▜▌                      │ No recent activity                                                                              │
    │                      ▝▜█████▛▘                     │                                                                                                 │
    │                        ▘▘ ▝▝                       │                                                                                                 │
    │  Sonnet 4.5 · Claude Max · quintin@zzz's           │                                                                                                 │
    │  Organization                                      │                                                                                                 │
    │  /…/Quintinwillison/code/CPC-Systems/Platform1-ROC │                                                                                                 │
    ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
                                                                                                                                                            
    ❯ /exit                                                                                                                                                 
      ⎿  Catch you later!                                                                                                                                   
                                                                                                                                                            
    ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
    ❯                                                                                                                                                       
    ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
      ⏸ plan mode on (shift+Tab to cycle)                                                                                                                   
    lima@lima-claude:/Users/Quintinwillison/code/CPC-Systems/Platform1-ROC$ which claude                                                                    
    /home/lima.linux/.local/bin/claude                                                                                                                      
    lima@lima-claude:/Users/Quintinwillison/code/CPC-Systems/Platform1-ROC$
    
  3. QuintinWillison commented on Jan 27, 2026

    @QuintinWillison

    Just had version 2.1.20 "Killed" (OOM, I presume) while engaging Opus for analysis on a new session. I had dropped my Ubuntu instance to just 2GB memory, but have now increased that back to 4GB. From this I conclude that Claude Code's memory footprint requirements have definitely increased since yesterday, as I was using it heavily yesterday all day with it never getting "Killed" - in fact, this morning was the first time I've encountered this after having been using Claude Code for a couple of months now!

  4. github-actions commented on Feb 28, 2026

    @github-actions

    Closing for now — inactive for too long. Please open a new issue if this is still relevant.

  5. github-actions commented on Mar 7, 2026

    @github-actions

    This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.

  6. locked as resolved and limited conversation to collaborators on Mar 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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