# Fix VS Code Extension Host Crashed Due to Memory Limit
VS Code suddenly stops providing IntelliSense, debugging, and extension features. A notification appears:
The extension host terminated unexpectedly.Or:
Extension host stopped responding. Do you want to restart it?Checking the Developer Tools console reveals:
[Extension Host] Error: ENOSPC: no space left on deviceOr:
[Extension Host] FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memoryThe extension host process has crashed, usually due to memory exhaustion.
Step 1: Identify the Crashing Extension
Open the Extension Host log:
Help > Toggle Developer Tools > ConsoleFilter for "Extension Host" messages. Look for the last extension that was activated before the crash:
[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:
{
"extensions.experimental.affinity": {
"ms-python.python": 1
}
}Or launch VS Code with increased memory:
code --max-memory=8192For the Electron process:
NODE_OPTIONS="--max-old-space-size=8192" codeThis 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:
code --disable-extension ms-python.pythonIf 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:
code --disable-extensionsIf 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:
{
"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:
Remove-Item "$env:APPDATA\Code\CachedData\*" -Recurse
Remove-Item "$env:APPDATA\Code\User\workspaceStorage\*" -RecurseOn macOS:
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:
Help > Start Extension BisectThis 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:
{
"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:
Help > Open Process ExplorerThis 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.