Why does VS Code require so much memory? How can I make it run more memory-efficiently?

Visual Studio-CodeRam

Visual Studio-Code Problem Overview


Does anyone know how to make VS Code use less memory?

It´s taking more than 2gb, sometimes more than 3 gigabytes to have some 8 files opened.

enter image description here

Visual Studio-Code Solutions


Solution 1 - Visual Studio-Code

I'm on the VS code team.

There are many possible causes for high memory usage. We've put together tools and a guide that can help you investigate potential performance issues.

Start by using the process explorer. The process explorer shows the cpu and memory usage per child process of VS Code. Open it with the Open process explorer command. The process explorer should help you track down which processes are using the most memory. Often times, an extension will turn out to be the root cause

enter image description here

Also, even though you have only opened eight files, your workspace seems to be quite a bit larger than just those eight. Providing intellisense and other advanced editor features often requires processing many unopened files as well. Whether or not the 2-3gb is justified or not is hard to say without understanding what extensions you are using and what your workspace contains.

I recommend that you also take a look through the rest of our performance issue guide. It explains how to report performance issues and further investigate performance problems.

Solution 2 - Visual Studio-Code

You could prevent vscode from watching folders with really many files in you project by adding this to your json settings file

"files.watcherExclude": {
    "**/.git/objects/**": true,
    "**/node_modules/**": true
} 

Solution 3 - Visual Studio-Code

It's because VS Code isn't a native program like Vim, Emacs, or even Sublime. Opening VS Code is like opening another Chrome window, it uses a lot of RAM, and CPU.

Neovim uses around 10 mbs of RAM (with some plugins), while vs code uses 700 mbs of RAM, with no file opened

Solution 4 - Visual Studio-Code

Because VSCode is built on top of Electron, so under the hood it is just the same as web browser. If you need more lighter memory use Sublime Text or Notepad++ instead

Solution 5 - Visual Studio-Code

Check if your extensions are causing the bad things

I have used the guide https://github.com/Microsoft/vscode/wiki/Performance-Issues#profile-the-running-extensions

to know why VS Code was

  • very slow to startup
  • taking much ram (3-4 gb)

> You can create a CPU profile and share it in the issue with the extension author or us. To create a CPU profile: > * Close all instances of VSCode and start with code --inspect-extensions=9993 or any other port number. > * Execute the Developer: Show Running Extensions Command. This command opens an editor with all the running extensions. To start recording a profile

I found some extension with high delays and they were marked with unresponsive yellow triangle. I disabled them using right click context menu, restarted VS Code, and after that it

  • Takes only a few seconds to startup
  • Takes only ~250mb of ram

Solution 6 - Visual Studio-Code

Not an actual solution, but launching VSC via code ./ --disable-extensionscan do so without requiring to manually disable all of them.

Solution 7 - Visual Studio-Code

This happened to me when I installed electron to my project it took something around 1.5 GB of Ram.. I tried uninstalling electron and now it takes just 250mb of ram..

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionAdriel WerlichView Question on Stackoverflow
Solution 1 - Visual Studio-CodeMatt BiernerView Answer on Stackoverflow
Solution 2 - Visual Studio-CodeCengkuru MichaelView Answer on Stackoverflow
Solution 3 - Visual Studio-CodeitzcompeterView Answer on Stackoverflow
Solution 4 - Visual Studio-CodeProgrammer DancukView Answer on Stackoverflow
Solution 5 - Visual Studio-CodeFindOutIslamNowView Answer on Stackoverflow
Solution 6 - Visual Studio-CoderoshnetView Answer on Stackoverflow
Solution 7 - Visual Studio-CodeAkhil BurleView Answer on Stackoverflow