Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VS Code crashing on restart after opening large file

I recently used VS code to open a large file by opening from the command line using the command line flag --max-memory=12288mb. I was able to edit the file fine and finished what I needed to do and then closed code as normal.

By default I have the restoreWindows and hotExit settings enabled, so that when I re-open code all the previous files are enabled.

After this whenever I open a VS Code via the shortcut or context menu, it attempts to re-open the large file and crashes within ~10 seconds of starting. And displays the warning:

The Window Has Crashed

We are sorry for the inconvenience! You can reopen the window to continue where you left off

enter image description here

I tried a few steps to attempt to close/prevent the file reopening all during the functioning 10 seconds:

  1. Close the tab using the 'x' icon
  2. Using the Close Editor, Close Folder and Close Window options in the file menu
  3. Setting "window.restoreWindows": "none" and "files.hotExit": "off" to try and prevent the file from automatically being reloaded

I have also tried running VS Code with extensions disabled

like image 781
Dan Gardner Avatar asked Sep 11 '19 10:09

Dan Gardner


People also ask

Why does Visual Studio code keep crashing?

If you experience crashes of Visual Studio, typically when working with a very large solution, your IDE might be out of virtual memory. Typical indicators of the problem include a "one or more errors occurred" message, "the process appears to be deadlocked" message, and OutOfMemory exception in a crash dump.

Can VS Code handle large files?

VS Code can't handle very large files (multi-GiB), but Sublime can. Hacker News. VS Code can't handle very large files (multi-GiB), but Sublime can.

How do I reset size VS Code?

View > Appearance > Reset Zoom (Ctrl+Numpad0) - reset the Zoom level to 0.


1 Answers

The solution was to start VS Code from the command line again with the following command

code --disable-extensions --max-memory=12288mb

Then to close the offending file and correctly exit VS Code without any open files. This then prevent VS Code from attempting to re-open the large file when restarting.

I believe that this is a bug in VS Code as it feels as though it should display the same warning to restart with the correct memory when re-loading files as it does when first attempting to open the file. I've raised a bug with MS here.

Hopefully this helps someone!

like image 89
Dan Gardner Avatar answered Sep 19 '22 02:09

Dan Gardner