# Fix VS Code Extension Host Crashed Due to Memory Limit

VS Code suddenly stops providing IntelliSense, debugging, and extension features. A notification appears:

bash
The extension host terminated unexpectedly.

Or:

bash
Extension host stopped responding. Do you want to restart it?

Checking the Developer Tools console reveals:

bash
[Extension Host] Error: ENOSPC: no space left on device

Or:

bash
[Extension Host] FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory

The extension host process has crashed, usually due to memory exhaustion.

Step 1: Identify the Crashing Extension

Open the Extension Host log:

bash
Help > Toggle Developer Tools > Console

Filter for "Extension Host" messages. Look for the last extension that was activated before the crash:

bash
[Extension Host] [ms-python.python] Activating extension...
[Extension Host] [ms-python.python] FATAL ERROR: ...

The extension listed just before the crash is likely the culprit.

Step 2: Increase Extension Host Memory Limit

By default, VS Code limits the extension host to a specific memory ceiling. Increase it:

json
{
    "extensions.experimental.affinity": {
        "ms-python.python": 1
    }
}

Or launch VS Code with increased memory:

bash
code --max-memory=8192

For the Electron process:

bash
NODE_OPTIONS="--max-old-space-size=8192" code

This increases the JavaScript heap size from the default (typically 4GB) to 8GB.

Step 3: Disable Problematic Extensions

Disable extensions one by one to isolate the crash:

bash
code --disable-extension ms-python.python

If the crash stops, that extension is the cause. Report the issue to the extension author and check for updates.

For a clean test, disable ALL extensions:

bash
code --disable-extensions

If the crash stops with all extensions disabled, re-enable them in groups of 5 to narrow down the culprit.

Step 4: Check for Extension Conflicts

Some extensions conflict with each other, causing memory leaks. Common conflicts:

  • Multiple Python extensions (e.g., Pylance + Jedi + Python)
  • Multiple formatters (Prettier + Beautify + ESLint)
  • Multiple Git extensions (GitLens + Git History + built-in Git)

Keep only one extension per category:

json
{
    "python.languageServer": "Pylance",
    "[python]": {
        "editor.defaultFormatter": "ms-python.black-formatter"
    }
}

Step 5: Check Disk Space for Extension Cache

The extension host uses disk-based caching. If the disk is full, it crashes:

```bash # Check disk space df -h

# Clear VS Code cache rm -rf ~/.config/Code/CachedData/* rm -rf ~/.config/Code/CachedExtensions/* rm -rf ~/.config/Code/User/workspaceStorage/* ```

On Windows:

powershell
Remove-Item "$env:APPDATA\Code\CachedData\*" -Recurse
Remove-Item "$env:APPDATA\Code\User\workspaceStorage\*" -Recurse

On macOS:

bash
rm -rf ~/Library/Application\ Support/Code/CachedData/*
rm -rf ~/Library/Application\ Support/Code/User/workspaceStorage/*

Step 6: Extension Bisect

VS Code has a built-in extension bisect tool:

bash
Help > Start Extension Bisect

This automatically disables half your extensions, asks if the problem persists, and narrows down to the specific extension causing the crash. It is the most efficient way to identify a problematic extension.

Step 7: Watch for File System Events

The extension host monitors file system changes. In large projects (e.g., node_modules with 100,000+ files), the file watcher can exhaust memory:

json
{
    "files.watcherExclude": {
        "**/.git/objects/**": true,
        "**/.git/subtree-cache/**": true,
        "**/node_modules/**": true,
        "**/dist/**": true,
        "**/build/**": true
    }
}

Excluding large directories from file watching significantly reduces memory usage.

Step 8: Monitor Extension Host Memory

Check the extension host memory usage:

bash
Help > Open Process Explorer

This shows a Task Manager-like view of VS Code processes. Look at the "Extension Host" process:

  • Normal: 200-500MB
  • High: 500MB-1GB (investigate)
  • Critical: >1GB (crash imminent)

If memory grows continuously over time, there is a memory leak. Disable extensions and monitor to find the leak.