Reputation: 413
VS Code takes 100% CPU usage even it is not open. I ran the ps aux | grep PID
command to check the details but can't understand anything. Here's the output:
tawhid 27099 100.0 0.1 447352160 11856 ?? R 7:18PM 151:14.95 /Applications/Visual Studio Code.app/Contents/Frameworks/Code Helper (Renderer).app/Contents/MacOS/Code Helper (Renderer) --ms-enable-electron-run-as-node /Applications/Visual Studio Code.app/Contents/Resources/app/out/bootstrap-fork --type=fileWatcher
tawhid 31889 0.0 0.0 408628368 1616 s000 S+ 10:28PM 0:00.00 grep 27099
Can anyone explain what process or extension uses so high CPU percentage? I have MacBook Air 2020. I have installed a lot of extensions out of curiosity.
Upvotes: 31
Views: 28635
Reputation: 323
One more reason for vscode to use CPU could be that there are lot's of files, in my case i had a folder inside project with >1kk folders (that i created for test purposes) and files inside and that caused hight CPU usage, because vscode continuously watches files to provide intelisense and autocompletion, after i deleted folder problem was fixed.
Upvotes: 0
Reputation:
By using the "Bisect utility," on VsCode I figured out that the problematic extension is Fig. https://fig.io
Upvotes: 0
Reputation: 8560
Try to disabled "Settings Sync".
Seems to be a bug related to electron. Visual Studio Code (VS Code) was built using Electron. Electron is a framework that allows developers to build cross-platform desktop applications using web technologies like HTML, CSS, and JavaScript electron. When the VSCode is lazy, open your OS manager tool (activity monitor on MacOS or taskmgr on Windows). Find the Electron process, generally it's using too much CPU (40%-100%) when VSCode is lazy.
Here is this issue thread on github
Edited 7/1/2022: Another issue related to "Code Helper (Renderer)". Sometimes it's take a huge amount of CPU.
Go to settings –> followSymlinks and disable it. Or edit the settings.json and put:
search.followSymlinks: false
Another process that may use a lot of CPU is Google Chrome Helper (Renderer). This process is created when the VSCode javascript debugger is active. It's responsible to interact between the browser and the VSCode debugger. Here a link to help you diagnose it
Another relevant factor is audit performance. (Ctrl+Shift+P: windows or command+p: mac) then type: > and then type: performance.
Developer: Show Running Extensions: to get the basic stats about the running extensions and find out some possible issue. It sorts the extensions from longest to shortest activation time. The time is titled "Startup Activation" if the extension is loaded on startup.
Debug: Take Performance Profile: Then choose the process that you want to get the analyze report.
Debug: Startup Performance: Will show bunch of information on startup of vsCode.
In my case to get rid of all potentially problematic extensions I have removed vscode and all his extension/caches/etc and reinstalled, in mac this procedure can be done following this steps:
1st: remove vs from applications folder
rm -rf ~/Library/Preferences/com.microsoft.VSCode.helper.plist
rm -rf ~/Library/Preferences/com.microsoft.VSCode.plist
rm -rf ~/Library/Caches/com.microsoft.VSCode
rm -rf ~/Library/Caches/com.microsoft.VSCode.ShipIt/
rm -rf ~/Library/Application\ Support/Code/
rm -rf ~/Library/Saved\ Application\ State/com.microsoft.VSCode.savedState/
rm -rf ~/.vscode*
Case all these steps have failed may you could try to downgrade VSCode to version 1.47 (in this version the current native debugger is not installed so all these involved processes aren't the same)
Upvotes: 65
Reputation: 588
I am on an m1 macbook air.
CPU would be 100% for a few minutes after running either tsc
or jest
on a nestjs project.
Using the Extension Profiler suggested by Cassio Seffrin (thank you!) I found this extension using the most CPU:
https://marketplace.visualstudio.com/items?itemName=kavod-io.vscode-jest-test-adapter
I uninstalled it, and my CPU issue has gone away completely. Your mileage may vary.
Upvotes: 0
Reputation: 21
I work on m1 pro, CPU usage was around 120-130
finally I used Extension Bisect to find the cause. For me it was "settings sync" by shan khan
after disabling everything works perfect
Upvotes: 2