Skip to content

Version 1.30.4 has a very, very, very serious memory leak and CPU usage problem. #14168

@LittleFatHero

Description

@LittleFatHero

Environment

  • OS and Version: windows 11 25H2
  • VS Code Version: 1.109
  • C/C++ Extension Version: 1.30.4
  • If using SSH remote, specify OS of remote machine: Ubuntu 20.04

Bug Summary and Steps to Reproduce

Bug Summary:
I open a aosp(Android Open Source Project), It keep doing IntelliSense and parsing workspace for a very long time, It never ended, lasting more than 5 hours. Most importantly, when it does this, VS Code becomes severely laggy and almost unusable. In VS Code, a thread was consuming over 5 GB of memory. When I closed the C++ plugin, the thread consuming 5 GB of memory disappeared. This proves that the C++ plugin has a serious memory leak issue; this thread was also consuming over 15% of CPU.

Steps to reproduce:
1.open vscode;
2. connect to remote machine ubuntu 20.04;
3. open aosp project;
4. open a C source file;

Expected behavior:
VS Code runs smoothly with low memory usage. Even with 5GB of memory used and over 15% CPU usage, VS Code shouldn't lag.

Configuration and Logs

{
    "$schema": "http://json-schema.org/draft-04/schema#",
    "type": "object",
    "definitions": {
        "configurations": {
            "type": "array",
            "items": {
                "type": "object",
                "required": [
                    "name"
                ],
                "properties": {
                    "name": {
                        "markdownDescription": "Configuration identifier. `Mac`, `Linux`, and `Win32` are special identifiers for configurations that will be auto-selected on those platforms, but the identifier can be anything.",
                        "descriptionHint": "Markdown text between `` should not be translated or localized (they represent literal text) and the capitalization, spacing, and punctuation (including the ``) should not be altered.",
                        "type": "string"
                    },
                    "compilerPath": {
                        "markdownDescription": "Full path of the compiler being used, e.g. `/usr/bin/gcc`, to enable more accurate IntelliSense.",
                        "descriptionHint": "Markdown text between `` should not be translated or localized (they represent literal text) and the capitalization, spacing, and punctuation (including the ``) should not be altered.",
                        "type": [
                            "null",
                            "string"
                        ]
                    },
                    "compilerArgs": {
                        "markdownDescription": "Compiler arguments to modify the includes or defines used, e.g. `-nostdinc++`, `-m32`, etc. Arguments that take additional space-delimited arguments should be entered as separate arguments in the array, e.g. for `--sysroot <arg>` use `\"--sysroot\", \"<arg>\"`.",
                        "descriptionHint": "Markdown text between `` should not be translated or localized (they represent literal text) and the capitalization, spacing, and punctuation (including the ``) should not be altered, except potentially the `arg` text which is a placeholder and not literal text, i.e. an abbreviation for `argument`.",
                        "type": "array",
                        "items": {
                            "type": "string"
                        }
                    },
                    "cStandard": {
                        "description": "Version of the C language standard to use for IntelliSense. Note: GNU standards are only used to query the set compiler to get GNU defines, and IntelliSense will emulate the equivalent C standard version.",
                        "type": "string",
                        "enum": [
                            "c89",
                            "c99",
                            "c11",
                            "c17",
                            "c23",
                            "gnu89",
                            "gnu99",
                            "gnu11",
                            "gnu17",
                            "gnu23",
                            "${default}"
                        ]
                    },
                    "cppStandard": {
                        "description": "Version of the C++ language standard to use for IntelliSense. Note: GNU standards are only used to query the set compiler to get GNU defines, and IntelliSense will emulate the equivalent C++ standard version.",
                        "type": "string",
                        "enum": [
                            "c++98",
                            "c++03",
                            "c++11",
                            "c++14",
                            "c++17",
                            "c++20",
                            "c++23",
                            "c++26",
                            "gnu++98",
                            "gnu++03",
                            "gnu++11",
                            "gnu++14",
                            "gnu++17",
                            "gnu++20",
                            "gnu++23",
                            "gnu++26",
                            "${default}"
                        ]
                    },
                    "compileCommands": {
                        "oneOf": [
                            {
                                "type": "string"
                            },
                            {
                                "type": "array",
                                "items": {
                                    "type": "string"
                                },
                                "uniqueItems": true
                            }
                        ],
                        "markdownDescription": "Full path or a list of full paths to `compile_commands.json` files for the workspace.",
                        "descriptionHint": "Markdown text between `` should not be translated or localized (they represent literal text) and the capitalization, spacing, and punctuation (including the ``) should not be altered."
                    },
                    "includePath": {
                        "markdownDescription": "A list of paths for the IntelliSense engine to use while searching for included headers. Searching on these paths is not recursive. Specify `**` to indicate recursive search. For example, `${workspaceFolder}/**` will search through all subdirectories while `${workspaceFolder}` will not. Usually, this should not include system includes; instead, set `C_Cpp.default.compilerPath`.",
                        "descriptionHint": "Markdown text between `` should not be translated or localized (they represent literal text) and the capitalization, spacing, and punctuation (including the ``) should not be altered.",
                        "type": "array",
                        "items": {
                            "type": "string"
                        }
                    },
                    "macFrameworkPath": {
                        "description": "A list of paths for the IntelliSense engine to use while searching for included headers from Mac frameworks. Only supported on Mac configuration.",
                        "type": "array",
                        "items": {
                            "type": "string"
                        }
                    },
                    "windowsSdkVersion": {
                        "markdownDescription": "Version of the Windows SDK include path to use on Windows, e.g. `10.0.17134.0`.",
                        "descriptionHint": "Markdown text between `` should not be translated or localized (they represent literal text) and the capitalization, spacing, and punctuation (including the ``) should not be altered.",
                        "type": "string",
                        "pattern": "^\\d{2}\\.\\d{1}\\.\\d{5}\\.\\d{1}$|^8\\.1$"
                    },
                    "dotConfig": {
                        "description": "A path to a .config file created by Kconfig system. Kconfig system generates a file with all the defines to build a project. Examples of projects that use Kconfig system are the Linux Kernel and NuttX RTOS.",
                        "type": "string"
                    },
                    "defines": {
                        "markdownDescription": "A list of preprocessor definitions for the IntelliSense engine to use while parsing files. Optionally, use `=` to set a value, e.g. `VERSION=1`.",
                        "descriptionHint": "Markdown text between `` should not be translated or localized (they represent literal text) and the capitalization, spacing, and punctuation (including the ``) should not be altered.",
                        "type": "array",
                        "items": {
                            "type": "string"
                        }
                    },
                    "intelliSenseMode": {
                        "markdownDescription": "The IntelliSense mode to use that maps to a platform and architecture variant of MSVC, gcc, or Clang. If not set or if set to `${default}`, the extension will choose the default for that platform. Windows defaults to `windows-msvc-x64`, Linux defaults to `linux-gcc-x64`, and macOS defaults to `macos-clang-x64`. IntelliSense modes that only specify `<compiler>-<architecture>` variants (e.g. `gcc-x64`) are legacy modes and are converted automatically to the `<platform>-<compiler>-<architecture>` variants based on the host platform.",
                        "descriptionHint": "Uses of words 'platform', 'compiler', and 'architecture' are meant to be descriptive placeholders for literal values, so they should be translated, but without changing the surrounding `<>-<>` symbols. All other text inside `` should not be translated or localized (they represent literal text) and the capitalization, spacing, and punctuation (including the ``) should not be altered.",
                        "type": "string",
                        "enum": [
                            "macos-clang-x86",
                            "macos-clang-x64",
                            "macos-clang-arm",
                            "macos-clang-arm64",
                            "macos-gcc-x86",
                            "macos-gcc-x64",
                            "macos-gcc-arm",
                            "macos-gcc-arm64",
                            "linux-clang-x86",
                            "linux-clang-x64",
                            "linux-clang-arm",
                            "linux-clang-arm64",
                            "linux-gcc-x86",
                            "linux-gcc-x64",
                            "linux-gcc-arm",
                            "linux-gcc-arm64",
                            "windows-clang-x86",
                            "windows-clang-x64",
                            "windows-clang-arm",
                            "windows-clang-arm64",
                            "windows-gcc-x86",
                            "windows-gcc-x64",
                            "windows-gcc-arm",
                            "windows-gcc-arm64",
                            "windows-msvc-x86",
                            "windows-msvc-x64",
                            "windows-msvc-arm",
                            "windows-msvc-arm64",
                            "clang-x86",
                            "clang-x64",
                            "clang-arm",
                            "clang-arm64",
                            "gcc-x86",
                            "gcc-x64",
                            "gcc-arm",
                            "gcc-arm64",
                            "msvc-x86",
                            "msvc-x64",
                            "msvc-arm",
                            "msvc-arm64",
                            "${default}"
                        ]
                    },
                    "forcedInclude": {
                        "description": "A list of files that should be included before any include file in a translation unit.",
                        "type": "array",
                        "items": {
                            "type": "string"
                        }
                    },
                    "configurationProvider": {
                        "description": "The id of a VS Code extension that can provide IntelliSense configuration information for source files.",
                        "type": "string"
                    },
                    "mergeConfigurations": {
                        "markdownDescription": "Set to `true` to merge `includePath`, `defines`, `forcedInclude`, and `browse.path` with those received from the configuration provider.",
                        "descriptionHint": "{Locked=\"`true`\"} {Locked=\"`includePath`\"} {Locked=\"`defines`\"} {Locked=\"`forcedInclude`\"} {Locked=\"`browse.path`\"}",
                        "type": "boolean"
                    },
                    "browse": {
                        "type": "object",
                        "properties": {
                            "limitSymbolsToIncludedHeaders": {
                                "markdownDescription": "Set to `true` to process only those files directly or indirectly included as headers. Set to `false` to process all files under the specified include paths.",
                                "descriptionHint": "Markdown text between `` should not be translated or localized (they represent literal text) and the capitalization, spacing, and punctuation (including the ``) should not be altered.",
                                "type": [
                                    "boolean",
                                    "string"
                                ]
                            },
                            "databaseFilename": {
                                "description": "Path to the generated symbol database. If a relative path is specified, it will be made relative to the workspace's default storage location.",
                                "type": "string"
                            },
                            "path": {
                                "markdownDescription": "A list of paths to use for indexing and parsing of workspace symbols (for use by 'Go to Definition', 'Find All References', etc.). Searching on these paths is recursive by default. Specify `*` to indicate non-recursive search. For example, `${workspaceFolder}` will search through all subdirectories while `${workspaceFolder}/*` will not.",
                                "descriptionHint": "Text in '' is a command and should be translated in the same way that VS Code itself translates it. Markdown text between `` should not be translated or localized (they represent literal text) and the capitalization, spacing, and punctuation (including the ``) should not be altered.",
                                "type": "array",
                                "items": {
                                    "type": "string"
                                }
                            }
                        },
                        "additionalProperties": false
                    },
                    "recursiveIncludes": {
                        "type": "object",
                        "properties": {
                            "reduce": {
                                "markdownDescription": "Set to `always` to always reduce the number of recursive include paths provided to IntelliSense to only those paths currently referenced by #include statements. This requires first parsing files to determine which headers are included. Set to `never` to provide all recursive include paths to IntelliSense. Reducing the number of recursive include paths may improve IntelliSense performance when a very large number of recursive include paths are involved. Not reducing the number of recursive include paths can improve IntelliSense performance by avoiding the need to parse files to determine which include paths to provide. The `default` value is currently to reduce the number of recursive include paths provided to IntelliSense.",
                                "descriptionHint": "Markdown text between `` should not be translated or localized (they represent literal text) and the capitalization, spacing, and punctuation (including the ``) should not be altered.",
                                "type": "string",
                                "enum": [
                                    "always",
                                    "never",
                                    "default",
                                    "${default}"
                                ]
                            },
                            "priority": {
                                "markdownDescription": "The priority of recursive include paths. If set to `beforeSystemIncludes`, the recursive include paths will be searched before system include paths. If set to `afterSystemIncludes`, the recursive include paths will be searched after system include paths. `beforeSystemIncludes` would more closely reflect the search order of a compiler, while `afterSystemIncludes` may result in improved performance.",
                                "descriptionHint": "Markdown text between `` should not be translated or localized (they represent literal text) and the capitalization, spacing, and punctuation (including the ``) should not be altered.",
                                "type": "string",
                                "enum": [
                                    "beforeSystemIncludes",
                                    "afterSystemIncludes",
                                    "${default}"
                                ]
                            },
                            "order": {
                                "markdownDescription": "The order in which subdirectories of recursive includes are searched.",
                                "type": "string",
                                "enum": [
                                    "depthFirst",
                                    "breadthFirst",
                                    "${default}"
                                ]
                            }
                        },
                        "additionalProperties": false
                    },
                    "customConfigurationVariables": {
                        "type": "object",
                        "markdownDescription": "Custom variables that can be queried through the command `${cpptools:activeConfigCustomVariable}` to use for the input variables in `launch.json` or `tasks.json`.",
                        "descriptionHint": "Markdown text between `` should not be translated or localized (they represent literal text) and the capitalization, spacing, and punctuation (including the ``) should not be altered.",
                        "patternProperties": {
                            "(^.+$)": {
                                "type": "string"
                            }
                        },
                        "additionalProperties": false
                    }
                },
                "additionalProperties": false
            }
        },
        "env": {
            "type": "object",
            "markdownDescription": "Custom variables that can be reused anywhere in this file using the `${variable}` or `${env:variable}` syntax.",
            "descriptionHint": "The word 'variable' within curly braces should be translated. The \"env\" should not be translated, and the capitalization, spacing, and punctuation (\"${:}\", including the ``) should be preserved.",
            "patternProperties": {
                "(?!^workspaceFolder$)(?!^workspaceRoot$)(?!^workspaceFolderBasename$)(?!^execPath$)(?!^pathSeparator$)(?!^default$)(^.+$)": {
                    "oneOf": [
                        {
                            "type": "string"
                        },
                        {
                            "type": "array",
                            "items": {
                                "type": "string"
                            }
                        }
                    ]
                }
            },
            "additionalProperties": false
        },
        "version": {
            "type": "integer",
            "description": "Version of the configuration file. This property is managed by the extension. Please do not change it."
        },
        "enableConfigurationSquiggles": {
            "type": "boolean",
            "markdownDescription": "Controls whether the extension will report errors detected in `c_cpp_properties.json`.",
            "descriptionHint": "Markdown text between `` should not be translated or localized (they represent literal text) and the capitalization, spacing, and punctuation (including the ``) should not be altered."
        }
    },
    "properties": {
        "configurations": {
            "$ref": "#/definitions/configurations"
        },
        "env": {
            "$ref": "#/definitions/env"
        },
        "version": {
            "$ref": "#/definitions/version"
        },
        "enableConfigurationSquiggles": {
            "$ref": "#/definitions/enableConfigurationSquiggles"
        }
    },
    "required": [
        "configurations",
        "version"
    ],
    "additionalProperties": false
}

Other Extensions

No response

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions