If VS Code closes with "The window terminated unexpectedly (reason: 'oom', code: '-536870904')" every time you reopen the same workspace, reopening it again is not a fix. The message means one of the editor's processes hit a memory limit and Chromium aborted it. The common advice to "give VS Code more memory" is also partly outdated: the old --max-memory flag and its companion setting were removed in 2023. This tutorial walks through a staged recovery: break the restore loop, capture the crash, work out whether a file, a workspace index, or an extension is responsible, and only then decide whether a targeted limit increase is justified.
Table of Contents
- What the OOM Message Means
- Step 1: Break the Restart Loop and Capture the Crash
- Step 2: Attribute the Crash to One of Three Triggers
- Step 3: Apply Targeted Fixes
- Step 4: Decide Whether Raising a Memory Limit Is Justified
- Step 5: Prevent the Crash from Coming Back
- Conclusion
What the OOM Message Means
reason: 'oom' is short for out of memory. The number is the part that confuses people. VS Code displays a signed 32-bit value, so the same code looks like this in hexadecimal:
-536870904 = 0xE0000008
That value is Chromium's kOomExceptionCode. Chromium's allocator header explains that 0xE0000008 was chosen because Windows error 0x08 is ERROR_NOT_ENOUGH_MEMORY, and the leading E keeps it out of the range of standard exception codes (Chromium's PartitionAlloc OOM header).
This is a process-level failure, not a report that every byte of system RAM is gone. The process may have hit its own JavaScript heap ceiling, an allocator limit, or the operating system's commit limit. That is why the crash can happen while your system monitor still shows free memory.
The dialog is about a window or renderer process. An extension host failure can surface differently and may not take down the window. On macOS or Linux, you may see a different exit signal or a "JavaScript heap out of memory" line instead of this Windows code, but the triage is the same: find the process that grew and the workload that made it grow.
Step 1: Break the Restart Loop and Capture the Crash
The first goal is to get a stable window long enough to collect evidence. Do not keep clicking Reopen with the same restored editors, because that recreates the condition that caused the crash.
-
Open a new session without restoring the previous one. The command-line reference documents
-nas opening a new session instead of restoring the previous session (VS Code command-line interface):
code -n ~/projects/big-app
If the crash dialog has a "Don't restore editors" checkbox, select it before reopening.
-
Start with extensions disabled if the folder still crashes. The same CLI reference documents
--disable-extensionsas disabling all installed extensions:
code --disable-extensions ~/projects/big-app
If the workspace opens normally, skip ahead to the extension trigger.
- Capture the process list while VS Code is alive. Run this from a terminal:
code --status
The VS Code performance guide recommends code --status and the built-in Process Explorer for narrowing down which process is responsible (VS Code performance issues). Open Process Explorer from Help > Open Process Explorer and watch the main process, window/renderer, extension host, and language servers. Look for the process that jumps or climbs before the crash.
- Separate your user state from the workspace. This starts an isolated instance with its own settings and extension state:
code --user-data-dir /tmp/vscode-oom-profile ~/projects/big-app
On Windows, use a path such as %TEMP%\vscode-oom-profile. If the crash disappears in the clean profile, your normal profile, workspace state, or an extension is involved.
- Note the timing. A crash within seconds of opening one file points to that file. Memory that climbs over minutes after opening a monorepo points to workspace indexing. A crash at startup points to an extension or restored state.
Keep the exact dialog text, the code, the workspace path, and the last file you opened. That is the minimum information you need to search for the error, file a useful bug report, or compare one crash with the next.
Step 2: Attribute the Crash to One of Three Triggers
VS Code is a multi-process Electron application. A process-level explanation of where VS Code's memory goes is useful here: the window, extension host, language servers, file watchers, search, source control, terminals, notebooks, and AI panels each hold memory independently (why VS Code uses so much memory). That is why the same 400 MB file can be harmless in one workspace and fatal in another.
| What you see | Likely trigger | Quick test |
|---|---|---|
| Crash seconds after opening one file; renderer memory jumps | One oversized file | Move or rename the file, then reopen the folder |
| Memory climbs over minutes on a monorepo; extension host or TypeScript server is large | An oversized workspace index | Open one package folder instead of the repository root |
| Crash at startup or after a specific command; stable with extensions off | An extension allocating on activation | Run with --disable-extensions, then bisect |
Trigger 1: One Oversized File
Logs, SQL dumps, minified JavaScript bundles, CSV exports, and generated JSON files are common culprits. The window process has to hold the text buffer, and a language extension may try to parse the file as well. VS Code has large-file handling that disables some memory-hungry features, but that is a mitigation, not a license to open a 400 MB log in the editor.
To confirm it, move the suspect file out of the workspace and reopen the folder with code -n. If the workspace is stable, put the file back and open it directly in a new window. If the crash returns only with that file, the file is the trigger.
The VS Code 1.75 release notes introduced workbench.editorLargeFileConfirmation, a setting that asks for confirmation before opening a file above a size you choose (VS Code 1.75 release notes). Setting it to 50 gives you a warning before a 400 MB file opens.
Trigger 2: An Oversized Workspace Index
Opening a monorepo root can activate language tooling for every package. The TypeScript server builds syntax trees and type information, the file watcher tracks folders, search indexes files, and source-control providers inspect the repository. Memory climbs gradually rather than spiking on a single file.
A quick test is to open the package you are actually working on instead of the root:
code ~/repo/packages/api
If that stays stable but the root crashes, you have an indexing problem. code --status will usually show the extension host or the TypeScript server as the large process.
Generated folders make this worse. A broad tsconfig.json include can pull in build output, test fixtures, and dependency type definitions. Opening the narrowest folder and excluding generated directories is usually a bigger win than adding RAM.
Trigger 3: An Extension Allocating on Activation
If VS Code dies at startup, or after a specific command, and --disable-extensions keeps it alive, an extension is involved. Heavy linters, AI assistants, Git tools, notebook extensions, and chat webviews are common sources. The extension host is a separate process, but extensions can still consume renderer memory through webviews and chat panels, and a leaking extension host can make the whole session unstable.
Use Extension Bisect to find the culprit. The performance guide describes Help: Start Extension Bisect, which disables half of your extensions, reloads the window, and asks whether the problem persists until a single extension remains. It is faster and more reliable than toggling extensions by hand.
If the crash started after a long AI chat or agent session, clear that session or start a new one before blaming the workspace. Long conversations and rendered tool output can hold a surprising amount of renderer memory.
Step 3: Apply Targeted Fixes
For an Oversized File
Keep large files out of the editor when you can. Terminal tools are faster and do not allocate a Chromium renderer:
less huge.log
lnav huge.log
head -n 200 huge.csv
sed -n '100000,100200p' huge.sql > slice.sql
For JSON, use jq on a slice. For a SQL dump, use the database client. For a minified JavaScript bundle, use source maps or format a copy outside VS Code rather than opening the bundle itself.
If you must open a large file occasionally, lower the confirmation threshold and keep large-file optimizations enabled:
{
"workbench.editorLargeFileConfirmation": 50,
"editor.largeFileOptimizations": true
}
The value is measured in megabytes, so 50 means VS Code asks before opening a file larger than 50 MB. Close the file before you close the window, and start with code -n next time so the previous session is not restored.
For an Oversized Workspace Index
Open the narrowest folder that contains your work:
code ~/repo/packages/api
If you need several packages, create a multi-root workspace with only those folders instead of opening the repository root.
Add excludes for generated directories in your workspace settings:
{
"files.watcherExclude": {
"**/node_modules/**": true,
"**/dist/**": true,
"**/build/**": true,
"**/.next/**": true,
"**/coverage/**": true,
"**/target/**": true
},
"search.exclude": {
"**/dist/**": true,
"**/build/**": true,
"**/.next/**": true,
"**/coverage/**": true,
"**/target/**": true
}
}
VS Code's exclude settings use glob patterns, and files.watcherExclude controls the file watcher while search.exclude controls search (VS Code's settings documentation on exclude patterns). The same 1.75 release added native glob support for files.watcherExclude, which makes those rules cheaper to apply on large trees.
search.exclude already skips node_modules, and the watcher defaults skip .git/objects, but neither knows about your dist, .next, or target directories. Add the ones your project actually generates.
For TypeScript projects, narrow the compiler's input as well:
{
"include": ["src"],
"exclude": ["node_modules", "dist", "build", "coverage"]
}
If the TypeScript server is still the process at the ceiling, do not raise its heap yet. Split the project first; Step 4 covers the one setting that is worth changing.
For an Extension
Confirm the extension is responsible with code --disable-extensions, then use Extension Bisect to identify it. Once you have a suspect, update it first. If the latest version still leaks, disable it for the current workspace only, using the extension's context menu and Disable (Workspace). That keeps it available in projects that need it while removing it from the workspace that crashes.
If the extension is an AI assistant, chat UI, or notebook tool, clear its session history and restart the extension host. A fresh session often removes a large accumulated cache without requiring a reinstall. Restart the extension host from the Command Palette or reload the window after changing extension settings.
For a Corrupted Workspace Cache
If the crash returns only for one workspace, and a clean --user-data-dir profile opens it, per-workspace state or a workspace-specific extension setting may be the problem. Close VS Code, then move the workspace storage folder aside:
Windows: %APPDATA%\Code\User\workspaceStorage
macOS: ~/Library/Application Support/Code/User/workspaceStorage
Linux: ~/.config/Code/User/workspaceStorage
Each subfolder corresponds to a workspace, and the workspace.json file inside points to the project path. Move the whole folder aside first, or only the matching subfolder. This resets per-workspace UI and extension state; some extensions also keep chat or index data there. It does not delete your source code or your user settings.
After the reset, open the workspace with code -n and open only the package you need. If the crash disappears, you have confirmed that something in the old workspace state or profile was part of the problem.
Step 4: Decide Whether Raising a Memory Limit Is Justified
Before changing any limit, know which limit you are changing. The old global knob is gone. The commit that removed the unsupported max_old_space_size option also deleted the --max-memory flag and the files.maxMemoryForLargeFilesMB setting (the VS Code commit that removed the old memory options). A VS Code maintainer also explained in issue #175792 that V8's heap in a process is capped at about 4 GB and that --max-memory had been removed (the VS Code issue on the 4 GB heap cap).
That means code --max-memory=8192 from an old blog post will not give the extension host 8 GB on a current build. It is not a supported current option, so do not build a fix around it. The same applies to files.maxMemoryForLargeFilesMB if you find it in an old settings file; current VS Code no longer registers that setting.
The 4 GB cap applies to the JavaScript heap in the extension host process. Typed arrays and other off-heap buffers can be larger, which is why a process total can exceed 4 GB in your system monitor. Ordinary strings, objects, and caches still hit the heap ceiling.
What you can raise is a specific language server's limit. The TypeScript wiki recommends splitting the project first, and only then raising typescript.tsserver.maxTsServerMemory to a reasonable upper limit while making sure the machine has enough memory (the VS Code TypeScript troubleshooting wiki):
{
"typescript.tsserver.maxTsServerMemory": 4096
}
Use this only when the TypeScript server is the process hitting its ceiling, and only after you have narrowed the workspace. Raising the limit on a leak just changes when the crash happens.
| Situation | Raise a limit? | Better first move |
|---|---|---|
| Memory is high but flat, the project is genuinely large, and the TypeScript server is near its cap | Maybe | Split the project, then raise one server's limit |
| Memory climbs while VS Code is idle | No | Find the leaking extension or report a bug |
| Crash happens only when opening one file | No | Keep that file out of the editor |
| Extension host is near 4 GB | No | Reduce workspace scope and extensions |
| The whole machine is swapping or hitting its commit limit | Sometimes | Add RAM or swap/page file, then fix the workload |
Machine headroom matters. On an 8 GB machine, a 4 GB language server plus Electron, the operating system, and a browser leaves almost nothing, so splitting the workspace is the safer choice. On 16 GB, a 4 GB server is plausible, but leave 6-8 GB for everything else and watch commit charge on Windows or swap usage on macOS and Linux. On 32 GB or more, a larger server is easier to justify, but per-process caps and leaks still apply. More RAM is not a fix for a process that grows without bound.
If the system commit limit is the actual failure, adding RAM or increasing swap/page file can stop the whole machine from failing. It will not fix a leak. Document any limit change in the workspace .vscode/settings.json so teammates know why it is there.
Step 5: Prevent the Crash from Coming Back
- Keep
workbench.editorLargeFileConfirmationat 50-100 MB so a huge log or dump produces a warning instead of a crash. - Keep
files.watcherExcludeandsearch.excludein workspace settings and commit them, so everyone gets the same indexing behavior. - Open the smallest folder that contains your work. Use a multi-root workspace only for the packages you are actively editing.
- Audit extensions periodically. Disable heavy ones per workspace and remove the ones you no longer use.
- Watch the baseline after a big workspace change. Open Process Explorer or run
code --status, and investigate any process that climbs while the editor is idle. The performance guide suggests Developer: Show Running Extensions and the Report Issue button when you need to file a leak. - Update VS Code and your extensions. Many memory leaks are fixed in later releases.
- Close long chat or agent sessions, notebooks, and large terminals when you are done. They hold rendered content and session state in the window process.
- Use terminal tools for logs and dumps as a habit. The fastest way to avoid an editor OOM is not to load the file into the editor.
Conclusion
The -536870904 code is Chromium's out-of-memory abort, shown as a signed 32-bit number. It tells you that a process hit a limit, not that you need to keep reopening the same workspace. Break the loop with code -n, capture the process list with code --status or Process Explorer, and attribute the crash to one oversized file, an oversized workspace index, or an extension. Fix the workload first. Only raise a targeted language-server limit when the process is genuinely near its ceiling and the machine has headroom, because the old global --max-memory knob is gone. With a lower large-file confirmation threshold, sensible excludes, and a habit of watching the extension host, the crash loop becomes a one-time diagnosis instead of a recurring interruption.
Top comments (0)