Reputation: 1042
I have noticed that Visual Studio Code randomly has a really high CPU usage. Generally, this seems to be related to the window where I have a SQL server project. Below is the output from code --status
when this recently happened. Any insights into what might be going on here?
code --status
Version: Code 1.27.1 (5944e81f3c46a3938a82c701f96d7a59b074cfdc, 2018-09-06T09:14:32.385Z)
OS Version: Darwin x64 17.7.0
CPUs: Intel(R) Core(TM) i9-8950HK CPU @ 2.90GHz (12 x 2900)
Memory (System): 32.00GB (2.58GB free)
Load (avg): 3, 3, 3
VM: 0%
Screen Reader: no
Process Argv: /Users/thebitguru/Desktop/Work/Visual Studio Code/Visual Studio Code.app/Contents/MacOS/Electron
GPU Status: 2d_canvas: enabled
checker_imaging: disabled_off
flash_3d: enabled
flash_stage3d: enabled
flash_stage3d_baseline: enabled
gpu_compositing: enabled
multiple_raster_threads: enabled_on
native_gpu_memory_buffers: enabled
rasterization: enabled
video_decode: enabled
video_encode: enabled
webgl: enabled
webgl2: enabled
CPU % Mem MB PID Process
87 131 4742 code main
0 131 4743 gpu-process
0 197 4744 window (~/golang/src/github.com/...PATH_MANUALLY_REMOVED.../auth.go — proj1)
0 98 5023 extensionHost
0 33 5024 watcherService
0 33 5033 searchService
77 262 4745 window (~/Desktop/...PATH_MANUALLY_REMOVED.../V20180905_4.0.18_1907.sql — db)
0 131 5025 extensionHost
0 98 5055 /Users/thebitguru/Desktop/Work/Visual Studio Code/code-portable-data/extensions/ms-mssql.mssql-1.4.0/sqltoolsservice/1.4.0/OSX/MicrosoftSqlToolsServiceLayer
0 66 5026 watcherService
0 33 5053 searchService
0 98 5027 shared-process
0 197 5121 window (~/Desktop/...PATH_MANUALLY_REMOVED.../messages.go — proj2)
0 98 5122 extensionHost
0 33 5123 watcherService
0 33 5128 searchService
Workspace Stats:
| Window (~/Desktop/...PATH_MANUALLY_REMOVED.../hermes.go — proj2)
| Window (~/Desktop/...PATH_MANUALLY_REMOVED.../V20180905_4.0.18_1907.sql — db)
| Window (~/golang/src/github.com/...PATH_MANUALLY_REMOVED.../auth.go — proj1)
| Folder (proj2): 35 files
| File types: go(23) log(2) yaml(2) gitignore(1) pid(1) md(1) mod(1)
| sum(1) txt(1) sql(1)
| Conf files: makefile(1)
| Folder (db): 175 files
| File types: sql(154) conf(7) txt(3) jar(3) DS_Store(2) gitignore(1)
| md(1) yml(1) cmd(1) dll(1)
| Conf files:
| Folder (proj1): 3846 files
| File types: go(3057) json(126) js(118) hcl(83) md(70) scss(54) s(50)
| gitignore(28) yml(27) txt(24)
| Conf files: package.json(60) makefile(6) launch.json(1)
| settings.json(1) tsconfig.json(1)
| Launch Configs: go
Upvotes: 40
Views: 44846
Reputation: 17109
If you have had this issue recently with an extension that consume your CPU, the bug is not from the extension but from core functionality of vscode
, It's because of a loop of promises that keeps processTicksAndRejections
busy in the affected extension host
Downgrading to 1.94.2
fixes this issue.
Upvotes: 0
Reputation: 7461
Just a suggestion for people, TL/DR: Update your extensions.
I've been having horrible CPU problems for quite a while. I'd start VSCode, it would begin indexing 60,000+ PHP files very slowly, top
showed a php task at 100% and any time I tried to use Nautilus (I'm on Gnome in Fedora) or opening files in Libreoffice Calc the file operations would hang for a good 10-20 seconds every single time. The file indexing in VSCode would appear to be processing 1-2 files each second at times; my entire morning was screwed every day.
If I quit VSCode, or disabled the Intellisense extension, the problem went away, so I didn't need to bisect extensions to find the cause.
I had tried using filesExclude
option in vscode to exclude the vendor
folder and others, but this didn't seem to change the number of files being indexed.
I found that in my Extensions pane in VSCode, you can Filter the pane by "Updates", and every one of my extensions had an update pending. Each one had an "auto update" checkbox that was not checked, this seems to be the default. So I spent a while updating them all and checking that checkbox. This included the PHP Intellisense extension, of course.
After this the problem completely went away, VSCode reindexes extremely quickly, and Nautilus and Calc are snappy again.
I imagine I was running years-old extension code, and was missing out on lots of performance improvements, bugfixes etc that had been implemented since the initial version I'd downloaded.
On a similar note, I see that as of today https://www.devsense.com/en/download/vscode?from=vscode lists a "pre-release" version of the Devsense PHP tools showing version 1.51.16000 will contain a fix "Fixes indexing of vendor when excluded from workspace #2100." which is an interesting point. It was this mention that made me think what version of the extension I had, and realised it was way out of date :) I'm currently on v1.51.15986 of the Devsense PHP "All-in-one" extension so I don't even have that yet, and my day has already become far more enjoyable.
Upvotes: 0
Reputation: 4877
This just happened to me and I used this guy's article to narrow it down in a few mins. https://remysharp.com/2022/09/17/vs-code-using-all-of-the-cpus-and-how-to-fix-it
Extension Bisect
Open the command palette (cmd+shift+p is my mac keyboard shortcut) and type "bisect" for "Help: Start Extension Bisect".
This then automates the entire process. It took me less than 5 minutes to find the extension that was causing all my headaches for months.
What's going to happen is that the utility is going to disable half of the extensions (temporarily) and restart VS Code. In my case I was "lucky" enough to have the offending extension consistently spiking the CPU.
The extension then asks if VS Code is behaving now or if it's still bad. Depending on your answer, it'll continue to bisect the extensions until (they estimate after about 8 times) you'll be left with the single offending extension:
The bisect prompt
Somehow I have 174 extensions, which with the prospect of doing this manually was terrifying. The extension bisect, because it's entirely automated, it tracks what it disabled, it tracks what the abort state is, and it means that it was incredibly quick to resolve.
Upvotes: 1
Reputation: 19
I had something similar. When I turned on the live server, the CPU usage increased. Found the solution here https://github.com/ritwickdey/vscode-live-server/issues/26 You need to add this to the live server settings file:
"liveServer.settings.NoBrowser" : true,
"liveServer.settings.ignoreFiles": [
"*",
"**"
]
Upvotes: 0
Reputation: 157
For me, Typescript, PHP extension pack for Xdebug, C/C++ extension, PHP Intellisense are not responsible for 100% CPU usage.
I disabled all the extensions but no luck.
I found that my Data folder of VSCode had not enough writable permission. After correcting permission, it is fine even after enabling all the extensions.
Upvotes: 0
Reputation: 1545
Faced same problem but in my case whas the PHP extension pack for Xdebug. I have disable that package and CPU under 10% again :D
Upvotes: 0
Reputation: 696
I have the same problem after I installed C/C++ extension in VScode. I think it is the VScode's bug. After I uninstalled this extension the high cpu problem was solved.
Upvotes: 1
Reputation: 221
I was also faced with this problem even my vs code was taking almost between 60% to 70% of CPU and also with memory usage. I have faced this problem for 1 month. I tried to reinstall another version of vs code more than 4-5 times. and also tried to disable some extensions. but nothing happened. the problem was that I had already installed a lot of extensions and added different projects to the workspace. This works for me when I removed unused projects folders from the workspace without disabling or uninstalling the extensions.
Upvotes: 0
Reputation: 17
I had the same issue where just typing into my JS project would cause my CPU use to skyrocket to 100% and when I stopped typing it would settle down at 12%. This was infuriating because it would cause everything else to hang, including the video player on Udemy.
So I decided to apply all the advice I found in this thread to my own issue but the issue still persisted. So I decided to disable my extensions one by one to see if that solved the issue.
Funnily enough, it was GitHub's own "GitHub Pull Requests and Issues" extension that caused my issue. Disabling it dropped my CPU usage from 100% to around 40%, which was a start!
As another user mentioned, try disabling your extensions methodically to see if that alleviates the issue.
Upvotes: 0
Reputation: 944
Try to increase the Max TS Server Memory.
saw here: https://github.com/microsoft/TypeScript/issues/38329
I did not want to disable TSServer because it helps with autocomplete, imports, etc.
Upvotes: 0
Reputation: 151
Its probably some extension. For me it was IntelliSense. Disable them one by one to check.
Upvotes: 2
Reputation: 349
Windows 10
I was also facing a similar problem with my VS Code. It was consuming huge amounts of power(HIGH) and also lots of CPU resources. For me, I was running a JavaScript application; So I guess, after selecting the Typescript: disable automatic type Acquisition
it worked for me and there was a significant improvement!
Even if you observe that your laptop is getting heated abnormally while using VS Code, you should try one of the approaches mentioned by others here!
Upvotes: 5
Reputation: 2993
first you need to find which process eating your cpu, for that vscode has inbuilt process Explorer. You can find at Help => Open Process Explorer
For me the culprit is electron_node tsserver.js,
I solved it by turning on the typescript.disableAutomaticTypeAcquisition, for that you need to go Settings => Extensions => TypeScript and check the Typescript: disable Automatic Type Acquisition
Upvotes: 56
Reputation: 1
I have the same problem when I import my whole user directory, e.g. /home/usr/ into visual code and eventually crashed my system. I resolved it by selecting specific working directory, e.g. /home/usr/Documents/work, and adding subsequent folders when needed. Then, my CPU usage back to normal
Upvotes: 0
Reputation: 81
Today my Visual Studio Code was draining my CPU and this happened after I had created a big bunch of files (6GB each of which being a couple of KB). I moved the files outside the scope of the editor and everything worked fine. I guess some extension or the editor itself was having a hard time indexing the files.
I hope this could help.
Upvotes: 1
Reputation: 168
I had the same issue today.
First I removed Php intelliSese Extension and my cpu usage came down to around 25%. Then I removed Vetur extension for Vuejs (I don't remember how or when I installed this), and now everything is running normal and cool.
Hopefully it helps you too.
Upvotes: 17