23

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.

Eros
  • 333
  • 1
  • 2
  • 5

4 Answers4

47

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

enter image description here

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

enter image description here

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)

Cassio Seffrin
  • 7,293
  • 1
  • 54
  • 54
  • 7
    Disabling Settings Sync is what did it for me! There are a lot of issues (https://github.com/shanalikhan/code-settings-sync/issues) being reported in the GitHub repo, and it seems like the plugin is no longer being maintained. Back to low idle CPU usage for me, awesome! – Nils Tijtgat Sep 01 '22 at 11:55
  • 1
    Thks for your feedback @NilsTijtgat. For me I have disabled all the features above and also I have removed unused plugins like flutter python etc. – Cassio Seffrin Sep 01 '22 at 12:01
2

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

0

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.

Gavin S
  • 579
  • 1
  • 9
  • 21
0

By using the "Bisect utility," I figured out that the problematic extension is Fig.

ArAsH
  • 122
  • 10