Reputation: 1211
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?
Upvotes: 25
Views: 30375
Reputation: 2641
In my case, I made several adjustments to fix the problem of VS Code overheating and causing my MacBook fan to go crazy. Here's what worked for me:
Disable Extensions depending on the Tech Stack
If working on a python project and Typescript and React extensions aren't required, disable them temporarily.
Removed Unused Extensions
I uninstalled all extensions that I wasn’t actively using. Keeping only essential extensions helped reduce resource usage.
Turned Off Auto-Import and Auto-Save
Disabling these features prevents unnecessary processes from running in the background.
Limit the Number of VS Code Instances
When working on projects requiring both an API and a front-end, Avoid opening two VS Code instances unless absolutely necessary. For example, if was working on a Rails (API) and React (front-end) project:
Open the front-end project in VS Code.
For the API, opt to use the terminal or Vim to navigate to the API directory and executed commands like rails s to start the Rails server, without opening the API project in VS Code. This will significantly reduce resource usage.
Clear Cache and Empty your bin
Regularly clear temporary files, cache, and empty your bin (trash) to free up disk space. Low storage can sometimes cause overheating and performance issues.
The final tip would be to get yourself a laptop fan cooler
Upvotes: 0
Reputation: 5439
I had a performance issue caused by the 'watcher' which watches for file changes. You can check if this is the issue for you by switching to the source control tab and checking to see if you have a blue line constantly spinning across the screen like in this image:
Another way to check is to go to View > Output > Git and you can see if it's going nuts in there:
In my case, I had changed the owner of the folder and so git no longer had access to read the file and it just didn't stop trying to read it! So my fix was to change ownership back and then my CPU and disk usage dropped instantly.
Upvotes: 0
Reputation: 11
In my case it was the shared-process that was using all of the available CPU. I removed all extensions, turned off sync and automatic upgrades, opened a single file in a clean directory. Nothing helped. VS Code was completely unusable. It just started doing this recently. I am at the latest SW version of VS Code (1.87.2). I used taskkill to kill the shared-process. The CPU recovered to normal and I haven't seen any problems in VS Code. Mind you, I only use VS Code as a file editor so maybe haven't noticed the impact of killing the shared-process.
Upvotes: 1
Reputation: 2591
Note: my goal was to know what consumes 100% CPU (extensions or vscode server).
htop
and see which vs code server process is doing that. In my case it was the 'pylance' extension. Use kill PID
to stop it. Your CPU levels should drop drastically now.Extra note: if you are opening the workspace on the root path '/' like I do the CPU reaching 100% is a normal thing because of vs code file watcher, you will see a warning popup from vs code about this anyway.
Upvotes: 1
Reputation: 50254
I'd recommend going through https://github.com/microsoft/vscode/wiki/Performance-Issues#consuming-cpu. What follows is an attempt at summary, but I'd suggest you just go read the thing directly.
The asker of this question had the same performance with extensions disabled, but if that isn't the case for you, you can use the builtin process monitor (Help > Open Process Explorer) to see if any extensions are consuming more CPU than the others (look at the "extensionHost" process to see if it's using a lot of CPU). To try reloading with extensions disabled, use the Developer: Reload With Extensions Disabled
command in the command palette. You can also do an extension bisect to try to figure out what extension is causing it.
If it's not caused by an extension, you can get more info by running code --status
in a terminal/shell while VS Code is already open. From the output of that command, you can get info about whether the CPU consumption is from the renderer/window process, the shared process, etc.
Upvotes: 1
Reputation: 4050
For most people, the culprit will be some extension. But extensions are often very useful for linting, auto completion, formatting etc. So, removing extensions altogether is not an option. But uninstall all unnecessary extensions, anyway.
Some tips will help to reduce this CPU usage. All we have to do is reduce the load for extensions.
Command + Shift + P
(or Ctrl + Shift + P
in windows and linux) and type >Local History: Delete All
and press Enter. This will clear all local history of files which will make some extensions faster.These steps are effective if you are working on large projects.
Upvotes: 0
Reputation: 30498
SysInternals-->Procmon64.exe to the rescue!
The culprit for me was that is was sitting in a location which was actually a network share. Once installing node-modules, there was background tracking of files which was making numerous TCP requests.
Using Procmon64.exe against the Code.Exe helped identify this.
Solution was to move to an area on the physical disk.
Upvotes: 0
Reputation: 1
The simplest solution to this problem is to load a smaller Workspace. I.e. if you open up the c:\ or /home directory, VS-Code will try to index all of the files. Instead only open up the directory of your project, i.e. c:\work\python\project1 .
No need to uninstall plugins.
Upvotes: -1
Reputation: 11
This is not a solution but a workaround:
If for any reason vscode continues using high cpu in linux, use cgroups feature of linux to control amount of cpu usage:
1- apt-get install cgroup-tools
2- create /etc/cgconfig.conf and add these lines:
group lowcpu {
cpu {
cpu.shares=100;
}
}
3- create /etc/cgrules.conf and add these lines:
*:vscode cpu lowcpu
*:code cpu lowcpu
4-run two commands:
cgconfigparser -l /etc/cgconfig.conf
cgrulesengd
reference: https://gist.github.com/avoidik/1c7c53f02461f716aabebf3372a6199d
Upvotes: 1
Reputation: 1
I had the same case. I deleted tons of no needed extensions. And now VS code doesn't use so much CPU.
Upvotes: 0
Reputation: 21
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.
Upvotes: 2
Reputation: 25
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.
Upvotes: 0
Reputation: 1081
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:
Hope this helps someone avoid the same frustration.
Upvotes: 0
Reputation: 421
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
Upvotes: 42
Reputation: 2933
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
}
Upvotes: 10
Reputation: 2658
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
Upvotes: 2