33

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.

6 Answers 6

68

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)

Sign up to request clarification or add additional context in comments.

4 Comments

Disabling Settings Sync is what did it for me! There are a lot of issues (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!
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.
It's 2024 now, but search.followSymlinks still generates 100% CPU. Is it still not fixed? Can't find any related issues in vscode repository
Indeed, Alex, AI has a lot of plugins for VSCode, but some settings still make VSCode slow
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

Comments

2

None of the above worked for me.

Summary: For me the issue is due to tsserver which is taking over 100% CPU and causing the IDE to lag.

-------

IDE Lag =>

  • Delayed intelisense

  • Copy Paste of code taking 3-5 seconds with loaders

  • Linter taking time to reflect errors ( in a file if some existing import is removed it takes a lot of time to show error[~15s] and adding back the import should remove the error which also takes around 10s.

------

What exactly is causing this

Open VSCode Process Explorer

  1. cmd + shift + p

  2. search for Developer: Open Process Explorer

  3. Keep it open, make some change in the code that involves type inference ( Remove some import, it should take some time )

  4. You will see electron-nodejs (tsserver.js) shooting up to 100+ and staying there for sometime - which is actually causing all the lag

enter image description here

------

Things I tried that confirmed it is not specific to IDE

  1. Tried everything in this stackoverflow thread, other sources - no luck.

  2. Clean Install VSCode/ Cursor - didn't fix.

  3. Tried Webstorm - the issue still exists

------

After bunch of trials, I noticed the issue is happening due a specific type in a specific file.

Here is how to find

Solution Here 🛠️

  1. List down all the open files in your VS Code when you notice the lag and close them all.

  2. Optionally open the VSCode Process Explorer to notice CPU usage.

  3. Open any other file (calling it TestFile) not from above list since the list has a culprit.

  4. Try removing some import in the TestFile and you should see the error reflects immediately and when you add the import back the error should go off almost instantly.

  5. Now from the list start opening one file at a time and check Step - 4

  6. If you notice a delay in Step-4 that should be your Culprit file.

  7. Remove all the type imports from the culprit file and replace them with any

  8. Step-4 Should work fine without any lag.

  9. Start adding one type at a time replacing any and check for Step-4.

  10. You will find the type that is causing the issue and replace that type with any

In my case the type is Ag-grid ColDef with a generic ColDef<Type>

PS: I updated the typescript version to latest which didn't help! So replacing with any is the best thing I could do. If you have a better solution comment it down.

Comments

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.

Comments

0

By using the "Bisect utility," on VsCode I figured out that the problematic extension is Fig. https://fig.io

Comments

0

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.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.