Skip to content

[BUG] VS Code extension crashes with OOM error: conversation history accumulates to 700MB+ causing infinite crash loop #8722

Closed as not planned

Description

@peterchabs

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?

The Claude Code VS Code extension crashes immediately on startup with an out-of-memory error and enters an infinite crash loop. The extension becomes completely unusable.

Root cause: The extension accumulates conversation history in ~/.claude/projects/ with no cleanup mechanism. In my case, a single project accumulated 738 MB of conversation data across 40+ .jsonl files, with the largest single file reaching 188 MB.

The extension appears to load all project conversation history into memory on startup, causing immediate crashes when the accumulated data exceeds available heap space.

Error from VS Code console:

What Should Happen?

  1. Conversation history should have automatic cleanup/retention policies (e.g., delete conversations older than 30 days)
  2. Individual conversation files should have size limits (e.g., 10 MB maximum)
  3. Total project data should be capped (e.g., 50-100 MB per project)
  4. Data should be loaded lazily on-demand rather than all at startup
  5. Users should receive warnings when approaching storage limits
  6. Extension should degrade gracefully rather than crash when limits are exceeded

Error Messages/Logs

[Extension Host] Spawning Claude Code process: node /Users/electrance/.vscode/extensions/anthropic.claude-code-2.0.3/resources/claude-code/cli.js ...

<--- Last few GCs --->
[2256:0x10c00300000] 29014 ms: Mark-Compact 2046.7 (2061.1) -> 2046.7 (2061.1) MB, 
pooled: 0.0 MB, 26.38 / 0.00 ms (average mu = 0.424, current mu = 0.025) 
allocation failure; scavenge might not succeed

[2256:1002/001230.303037:ERROR:electron/shell/common/node_bindings.cc:178] 
OOM error in V8: Reached heap limit Allocation failed - JavaScript heap out of memory

Extension host (LocalProcess pid: 2256) terminated unexpectedly. 
Code: 5, Signal: unknown

Automatically restarting the extension host.

Steps to Reproduce

  1. Install Claude Code VS Code extension (2.0.3)
  2. Use the extension extensively on a single project over weeks/months
  3. Have extended coding sessions with long conversations
  4. Allow conversation history to accumulate indefinitely in ~/.claude/projects/
  5. Restart VS Code
  6. Observe extension host crash within 30 seconds with OOM error

To verify the issue:

# Check project data size
du -sh ~/.claude/projects/*

# In my case:
# 738M ~/.claude/projects/-Users-electrance-YolkWebApp-working/

# Check individual conversation files
du -sh ~/.claude/projects/[your-project]/*

# Largest files in my case:
# 188M for a single .jsonl file
# Multiple 30-87 MB files

### Claude Model

Sonnet (default)

### Is this a regression?

Yes, this worked in a previous version

### Last Working Version

1.0.127

### Claude Code Version

anthropic.claude-code-2.0.3

### Platform

Anthropic API

### Operating System

macOS

### Terminal/Shell

Other

### Additional Information

Workaround to temporarily fix:

# Back up and remove the project directory
mv ~/.claude/projects/[your-project] ~/.claude/projects/[your-project].backup
# Restart VS Code - extension will work again with fresh project


**Additional Information**
```markdown
**Data accumulation details:**
~/.claude/ directory breakdown:

projects/: 744 MB total

Single project: 738 MB
40+ conversation .jsonl files
Largest single file: 188 MB


file-history/: 21 MB
todos/: 704 KB
shell-snapshots/: 456 KB


**Impact:**
- Extension becomes completely unusable after extended use
- No warning before catastrophic failure
- Requires file system intervention to fix
- Non-technical users cannot diagnose or resolve
- Risk of losing conversation history when forced to delete project data

**Observations:**
- Issue is silent - no indication of accumulating data
- No automatic cleanup mechanism exists
- Extension loads ALL project data into memory at startup
- Problem compounds over time with extended use

Activity

  1. github-actions commented on Oct 2, 2025

    @github-actions

    Found 3 possible duplicate issues:

    1. History accumulation in .claude.json causes performance issues and storage bloat #5024
    2. Critical: .claude.json bloat severely impacting user experience - consolidated community feedback #6394
    3. Recurring crashes: JavaScript Heap Out of Memory while 'thinking' #1421

    This issue will be automatically closed as a duplicate in 3 days.

    • If your issue is a duplicate, please close it and 👍 the existing issue instead
    • To prevent auto-closure, add a comment or 👎 this comment

    🤖 Generated with Claude Code

  2. peterchabs commented on Oct 2, 2025

    @peterchabs
    Author

    This is specific to Sonnet 4.5:

    I am leaving this issue open even though I see some similar issues (Not through VS Code) submitted weeks ago due to this only becoming an issue for me on the v 2.x.x releases. Reverting to 1. 0.127 which was released a few days ago still works perfectly fine, this is the temporary fix for this issue until a permanent fix is committed.

    Workaround to temporarily fix:

    Back up and remove the project directory

    mv ~/.claude/projects/[your-project] ~/.claude/projects/[your-project].backup

    Restart VS Code - extension will work again with fresh project

  3. djf1982 commented on Oct 2, 2025

    @djf1982

    I have exactly the same issue. It is unique to the VS Code extension, Claude Code in the terminal does not load all project history into memory at startup.

    I worked around it by clearing my convo history ;-) I expect to have to repeatedly do this until this is fixed.

  4. corylanou commented on Oct 2, 2025

    @corylanou

    I'm not running the extension, I'm just running Claude code cli in cursor, and I got an out of memory today on 2.0.1:

    ⏺ You're absolutely right. Let me rewrite this as a clean, direct implementation plan without the discovery narrative:
    RangeError: Out of memory
        at join (unknown)
        at q9Z (/$bunfs/root/claude:787:13450)
        at M (/$bunfs/root/claude:787:11696)
        at Z (/$bunfs/root/claude:787:11951)
        at PgY (/$bunfs/root/claude:947:9184)
        at <anonymous> (/$bunfs/root/claude:948:781)
        at useMemo (/$bunfs/root/claude:36:25924)
        at iI (/$bunfs/root/claude:947:7964)
        at Kw (/$bunfs/root/claude:36:19415)
        at $d (/$bunfs/root/claude:38:42805)
    
      ERROR  Out of memory
    
     -     at join (unknown)
     - q9Z (/$bunfs/root/claude:787:13450)
     - M (/$bunfs/root/claude:787:11696)
     - Z (/$bunfs/root/claude:787:11951)
     - PgY (/$bunfs/root/claude:947:9184)
     - <anonymous> (/$bunfs/root/claude:948:781)
     - useMemo (/$bunfs/root/claude:36:25924)
     - iI (/$bunfs/root/claude:947:7964)
     - Kw (/$bunfs/root/claude:36:19415)
     - $d (/$bunfs/root/claude:38:42805)
     - ```
    
  5. peterchabs commented on Oct 6, 2025

    @peterchabs
    Author

    I'm not running the extension, I'm just running Claude code cli in cursor, and I got an out of memory today on 2.0.1:

    ⏺ You're absolutely right. Let me rewrite this as a clean, direct implementation plan without the discovery narrative:
    RangeError: Out of memory
        at join (unknown)
        at q9Z (/$bunfs/root/claude:787:13450)
        at M (/$bunfs/root/claude:787:11696)
        at Z (/$bunfs/root/claude:787:11951)
        at PgY (/$bunfs/root/claude:947:9184)
        at <anonymous> (/$bunfs/root/claude:948:781)
        at useMemo (/$bunfs/root/claude:36:25924)
        at iI (/$bunfs/root/claude:947:7964)
        at Kw (/$bunfs/root/claude:36:19415)
        at $d (/$bunfs/root/claude:38:42805)
    
      ERROR  Out of memory
    
     -     at join (unknown)
     - q9Z (/$bunfs/root/claude:787:13450)
     - M (/$bunfs/root/claude:787:11696)
     - Z (/$bunfs/root/claude:787:11951)
     - PgY (/$bunfs/root/claude:947:9184)
     - <anonymous> (/$bunfs/root/claude:948:781)
     - useMemo (/$bunfs/root/claude:36:25924)
     - iI (/$bunfs/root/claude:947:7964)
     - Kw (/$bunfs/root/claude:36:19415)
     - $d (/$bunfs/root/claude:38:42805)
     - ```
    

    ahh yes, seems to be specific to Sonnet 4.5. I'm shocked this is still unresolved.

  6. akshay-nm commented on Nov 28, 2025

    @akshay-nm

    this is still an issue with 2.0.55, i am running the extension, or trying to get it up and running.
    Opening a chat causes the extension host to crash.
    [BUG] Claude code extension memory leak issue #12611

  7. sibidharan commented on Nov 28, 2025

    @sibidharan

    Having same issue, I deleted the large jsonl from ~/.claude/projects/-project-dir caused the restart loop to stop! But it causes the history to go away - reading the files, they are the chat history.

  8. akshay-nm commented on Nov 28, 2025

    @akshay-nm

    Having same issue, I deleted the large jsonl from ~/.claude/projects/-project-dir caused the restart loop to stop! But it causes the history to go away - reading the files, they are the chat history.

    did you delete all the json files in the project dir?

  9. 1 remaining item

  10. peterchabs commented on Jan 5, 2026

    @peterchabs
    Author

    Just posting here again to confirm as of just now, this issue is still unresolved and continues happening.

  11. corylanou commented on Jan 5, 2026

    @corylanou

    I finally gave up on visual code/cursor. They can't handle the amount of agents/sessions I have open. Went back to ghostty/tmux. total game changer. Using 10% of the memory I was with the visual code/cursor ide's. Turns out it wasn't ever claudes or codexes fault (I was having issues with both the cli's). No the answer people probably want to hear, but I've gone a week straight of power coding with agents (probably 30+ sessions all running at once) and have yet to have a single cli crash, or have to restart anything on my system. That's proof enough for me what the real cause was...

  12. lachlanhawthorne commented on Feb 4, 2026

    @lachlanhawthorne

    Confirmed fix: The root cause was accumulated conversation history files.

    In my case: 955 JSONL files totaling 2GB in ~/.claude/projects/[project-dir]/

    Solution:

    # Check your history size
    du -sh ~/.claude/projects/*
    
    # Delete old conversation history
    rm -rf ~/.claude/projects/[your-project-dir]/*.jsonl

    After clearing, the VS Code extension works perfectly again. The extension tries to load all history into memory on startup, causing OOM when history accumulates.

  13. lachlanhawthorne commented on Feb 4, 2026

    @lachlanhawthorne

    Credit to @peterchabs and @sibidharan above for identifying this fix - just confirming it still works in v2.1.31 and adding the diagnostic commands.

  14. codybrom commented on Feb 11, 2026

    @codybrom

    Reproduced on:

    • Claude Code v2.1.39
    • VS Code 1.109.2 arm64
    • macOS 26.2
    • 502 conversation files

    Key finding: VS Code Copilot Chat's Archive feature doesn't prevent OOM

    I archived 468/502 conversations via Chat sidebar. Confirmed archived in workspace state DB (state.vscdb):

    sqlite3 state.vscdb "SELECT value FROM ItemTable WHERE key = 'agentSessions.state.cache'"
    → 468 sessions with "archived": true  
    → 0 active sessions

    VS Code Copilot Chat's archive feature is useless for preventing OOM crashes. It's purely cosmetic UI filtering that happens AFTER files are already loaded into memory.

  15. therbta commented on Feb 11, 2026

    @therbta

    I had the same issue. My Claude history folder grew to 2.6GB.
    Fix: cleared history and kept only the latest 20 conversations (now ~466MB).
    Credit to @lachlanhawthorne for identifying a solution.

    Problem

    Claude extension slow/fails to load due to large conversation history (~2GB+).

    The Script

    Create scripts/cleanup-claude-history.js:

    #!/usr/bin/env node
    import { execSync } from 'child_process';
    import path from 'path';
    import os from 'os';
    
    const KEEP_COUNT = 20;
    const PROJECT_DIR = path.join(
      os.homedir(),
      '.claude',
      'projects',
      '-Users-YOUR-PATH-HERE' // Update with your project directory name
    );
    
    try {
      const checkDir = `[ -d "${PROJECT_DIR}" ] && echo "exists" || echo "missing"`;
      const dirExists = execSync(checkDir, { encoding: 'utf8' }).trim();
    
      if (dirExists !== 'exists') {
        console.log('✓ Claude history directory not found');
        process.exit(0);
      }
    
      const countCmd = `find "${PROJECT_DIR}" -maxdepth 1 -name "*.jsonl" | wc -l`;
      const currentCount = parseInt(execSync(countCmd, { encoding: 'utf8' }).trim());
    
      if (currentCount <= KEEP_COUNT) {
        console.log(`✓ Claude history OK (${currentCount} files)`);
        process.exit(0);
      }
    
      const cleanupCmd = `cd "${PROJECT_DIR}" && ls -t *.jsonl 2>/dev/null | tail -n +${KEEP_COUNT + 1} | xargs rm -f`;
      execSync(cleanupCmd);
    
      console.log(`✓ Cleaned ${currentCount - KEEP_COUNT} old files, kept ${KEEP_COUNT}`);
    } catch (error) {
      console.log('⚠ Cleanup skipped');
    }

    Find Your Project Directory

    ls ~/.claude/projects/
    # Look for directory matching your project path

    Auto-Run Options

    1. npm start

    "prestart": "node scripts/cleanup-claude-history.js && ..."

    2. VSCode (on folder open) - Add to .vscode/tasks.json:

    {
      "label": "Cleanup Claude History",
      "type": "shell",
      "command": "node scripts/cleanup-claude-history.js",
      "runOptions": { "runOn": "folderOpen" }
    }

    3. Daily (3 AM)

    crontab -e
    # Add: 0 3 * * * node /path/to/scripts/cleanup-claude-history.js

    4. Manual

    node scripts/cleanup-claude-history.js
  16. github-actions commented on Mar 11, 2026

    @github-actions

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

  17. github-actions commented on Mar 19, 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.

  18. locked as resolved and limited conversation to collaborators on Mar 19, 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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions