'Visual Studio Code using large amounts of CPU

I'm running Windows 10. VSCode, even when idle, takes up a consistent 26-30% of my cpu. I tried code --disable-extensions in CMD to check if an extension was causing the problem, but my performance was the same as with extensions.

When I used sublime text, I had a similar issue with the editor using large amounts of cpu on idle - the problem was with indexing, which could be turned off with a single line of code in the settings. I tried looking up indexing on VSCode, but I couldn't find anything pertaining to my issue. What could be the problem?



Solution 1:[1]

For me the solution was disable extension auto updates and some extra settings for the search engine. The most efficient one was search.followSymlinks": false. I share my settings.json file.

"files.exclude": {
        "**/tmp/**": true,
        "**/node_modules/**": true,
        "**/.git/objects/**": true,
},
"files.watcherExclude": {
        "**/.git/objects/**": true,
        "**/.git/subtree-cache/**": true,
        "**/node_modules/**": true,
        "**/tmp/**": true,
        "**/dist/**": true
},
"search.exclude": {
        "**/node_modules/**": true,
        "**/dist/**": true,
        "**/tmp/**": true,
        "**/.git/objects/**": true,
        "**/.git/subtree-cache/**": true
},
"extensions.autoCheckUpdates": false,
"extensions.autoUpdate": false,
"search.followSymlinks": false

Solution 2:[2]

VS code uses the file watcher to identify any changes in the files. You can exclude the folders containing multiple files and not require to watch continuously.

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

Solution 3:[3]

For me what solved the problem was turning off Auto Import extension, was working on a huge project, and only once I opened that project the VS Code started eating up my CPU, in the left bottom corner it said Scanning... I right clicked on it, and "manage extensions" appeared I clicked on it and immediately went to Auto Import extension, I turned it off and everything was back to normal. So point being try checking bottom left corner for some processes and try disabling those process and hopefully it works, or for at least some of you.

[EDIT] What you could also do is open Task Manager and you would see something like \> Visual Studio Code (8) I would click on the arrow to see the list of all VS Code processes and kill only those (in my case only one) that was/were making all the problems

Solution 4:[4]

My Visual Studio Code CPU usage is high during startup, but decreases in under a minute. The computer is unusable during that minute - mouse and keyboard do not respond and the fans are full on.

Microsoft Live Share extension seems to be the culprit in my case. I am on Windows 10 using the Live share extension on a moderately sized repository.

Steps to reproduce:

  1. Open the repository folder in VSCode
  2. Install Live Share extension
  3. Close VSCode
  4. Reopen VSCode
  5. Observe 100% CPU and unusable mouse/keyboard for about 10 to 60 seconds
  6. Disable extension
  7. Close VSCode
  8. Reopen VSCode
  9. Observe no unusually high CPU

Hope this helps someone avoid the same frustration.

Solution 5:[5]

Additionnaly to visual studio internal configuration you can fiddle with you Os's configs for it.

Beware to not clutter your scheduler, you must know what you're doing before "trying out".

On linux, you can adjust the NICE value for each process for instance. The equivalent on windows is described in the following article : https://www.itechtics.com/limit-cpu-usage/. Make some research if you aren't confident.

Solution 6:[6]

In the last two days, I have tried everything so far I have seen on GitHub,freecodecamp, StackOverflow. Changed JSON settings, uninstall every extension, reinstalling vscode. still its consuming 80-95% percent of CPU.

Solution 7:[7]

The CPU went 100% for Electron each time I opened xml files. When I open more than one project, I get several CPU 100% Electron processes that freeze my mac.

This configuration solved it for me

settings.json

"files.exclude": {
    "*.xml": true
}

Source for the idea came from: https://vscode-docs.readthedocs.io/en/latest/supporting/faq/

The CPU for Electron is 0.1% now :)

Hope it will help someone with the same issue.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Diego Méndez
Solution 2 Bilash
Solution 3
Solution 4 Thomas Portwood
Solution 5 Zoyolin
Solution 6 taiyeb nirjhor
Solution 7