Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ms-vscode.cpptools taking a ton of CPU usage

I'm working on Ubuntu and using MS Remote SSH as part of Remote Explorer through VSCode. When I installed C/C++ (ms-vscode.cpptools) extension, it takes up a ton of CPU%, typically around 95. I thought perhaps this is a one time thing, but it's constantly running at that percentage, making everything else (compiling the project) very slow.

I like the functionality of this extension, as I've used it on other machines before without issue. However I can't use it if it's staying at that level of usage. Is there any workaround for this? I've seen a few github debates, but nothing much coming from those.

From system monitor: enter image description here

like image 862
user14524171 Avatar asked Sep 12 '25 14:09

user14524171


2 Answers

After trying lots of solutions, only one works for me - adding files.exclude in settings file.

When adding files.exclude, the following lines will be add by default:

"**/.git": true,
"**/.svn": true,
"**/.hg": true,
"**/.deps": true,
"**/CVS": true,
"**/.DS_Store": true,

then I add some files/folder, which are in workspace but they have nothing to do with IntelliSense, such as "**/*.Po", folder that stores test data (lots of files...), which are always been updated when I use my application, etc.

and I also add

"/bin": true,
"/boot": true,
"/cdrom": true,
"/dev": true,
"/proc": true,
"/etc":true

, but I am not sure if those lines help.

After updating the settings file, we should Restart IntelliSense for Active File and Reset IntelliSense Database by the Command Palette.

btw, after using the above solution, I haven't encountered long-running high CPU usage for over two months.

like image 51
Leo SHEN Avatar answered Sep 16 '25 09:09

Leo SHEN


I have set C_Cpp.files.exclude to exclude everything and then set explicit include paths in c_cpp_properties.json and it seems to work fine. It does not keep scanning files anymore and resolves symbols correctly.

My settings.json

{
  "C_Cpp.files.exclude": {
    "**/.vscode": true,
    "**/.vs": true,
    "/": true
  }
}

Example c_cpp_properties.json:

{
  "configurations": [
    {
        "name": "Linux",
        "includePath": [
            "${workspaceFolder}/include/**"
            "${workspaceFolder}/src/**"
        ],
        "compilerPath": "/usr/bin/clang-14",
        "cStandard": "gnu17",
        "cppStandard": "gnu++17",
        "intelliSenseMode": "linux-clang-x64",
        "configurationProvider": "ms-vscode.makefile-tools"
    }
  ],
  "version": 4
}
like image 24
offlinehacker Avatar answered Sep 16 '25 09:09

offlinehacker