Skip to content

Commit 7dcf4db

Browse files
Add memory usage limit of an IntelliSense process (#6240)
1 parent eac4703 commit 7dcf4db

File tree

5 files changed

+16
-2
lines changed

5 files changed

+16
-2
lines changed

Extension/package.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -848,6 +848,14 @@
848848
"scope": "machine-overridable",
849849
"minimum": 0
850850
},
851+
"C_Cpp.intelliSenseMemoryLimit": {
852+
"type": "number",
853+
"default": 4096,
854+
"description": "%c_cpp.configuration.intelliSenseMemoryLimit.description%",
855+
"scope": "machine-overridable",
856+
"minimum": 256,
857+
"maximum": 16384
858+
},
851859
"C_Cpp.default.includePath": {
852860
"type": [
853861
"array",

Extension/package.nls.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,8 @@
132132
"c_cpp.configuration.commentContinuationPatterns.description": "Defines the editor behavior for when the Enter key is pressed inside a multiline or single line comment block.",
133133
"c_cpp.configuration.configurationWarnings.description": "Determines whether pop up notifications will be shown when a configuration provider extension is unable to provide a configuration for a source file.",
134134
"c_cpp.configuration.intelliSenseCachePath.description": "Defines the folder path for cached precompiled headers used by IntelliSense. The default cache path is \"%LocalAppData%/Microsoft/vscode-cpptools\" on Windows, \"$XDG_CACHE_HOME/vscode-cpptools/\" on Linux (or \"$HOME/.cache/vscode-cpptools/\" if XDG_CACHE_HOME is not defined), and \"$HOME/Library/Caches/vscode-cpptools/\" on Mac. The default path will be used if no path is specified or if a specified path is invalid.",
135-
"c_cpp.configuration.intelliSenseCacheSize.description": "Maximum size of the per-workspace hard drive space in megabytes for cached precompiled headers; the actual usage may fluctuate around this value. The default size is 5120 MB. Precompiled header caching is disabled when the size is 0.",
135+
"c_cpp.configuration.intelliSenseCacheSize.description": "Maximum size of the per-workspace hard drive space in megabytes (MB) for cached precompiled headers; the actual usage may fluctuate around this value. The default size is 5120 MB. Precompiled header caching is disabled when the size is 0.",
136+
"c_cpp.configuration.intelliSenseMemoryLimit.description": "Memory usage limit in megabytes (MB) of an IntelliSense process. The default limit is 4096 MB and the maximum limit is 16 GB. The extension will shutdown and restart an IntelliSense process when it exceeds the limit.",
136137
"c_cpp.configuration.default.includePath.description": "The value to use in a configuration if \"includePath\" is not specified in c_cpp_properties.json. If \"includePath\" is specified, add \"${default}\" to the array to insert the values from this setting.",
137138
"c_cpp.configuration.default.defines.description": "The value to use in a configuration if \"defines\" is not specified, or the values to insert if \"${default}\" is present in \"defines\".",
138139
"c_cpp.configuration.default.macFrameworkPath.description": "The value to use in a configuration if \"macFrameworkPath\" is not specified, or the values to insert if \"${default}\" is present in \"macFrameworkPath\".",

Extension/src/LanguageServer/client.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -905,6 +905,7 @@ export class DefaultClient implements Client {
905905
const settings_defaultSystemIncludePath: (string[] | undefined)[] = [];
906906
const settings_intelliSenseCachePath: (string | undefined)[] = [];
907907
const settings_intelliSenseCacheSize: (number | undefined)[] = [];
908+
const settings_intelliSenseMemoryLimit: (number | undefined)[] = [];
908909
const settings_autoComplete: (string | undefined)[] = [];
909910
const workspaceSettings: CppSettings = new CppSettings();
910911
const workspaceOtherSettings: OtherSettings = new OtherSettings();
@@ -1057,6 +1058,7 @@ export class DefaultClient implements Client {
10571058
settings_defaultSystemIncludePath.push(setting.defaultSystemIncludePath);
10581059
settings_intelliSenseCachePath.push(util.resolveCachePath(setting.intelliSenseCachePath, this.AdditionalEnvironment));
10591060
settings_intelliSenseCacheSize.push(setting.intelliSenseCacheSize);
1061+
settings_intelliSenseMemoryLimit.push(setting.intelliSenseMemoryLimit);
10601062
settings_autoComplete.push(setting.autoComplete);
10611063
}
10621064

@@ -1181,6 +1183,7 @@ export class DefaultClient implements Client {
11811183
intelliSenseCacheDisabled: intelliSenseCacheDisabled,
11821184
intelliSenseCachePath : settings_intelliSenseCachePath,
11831185
intelliSenseCacheSize : settings_intelliSenseCacheSize,
1186+
intelliSenseMemoryLimit : settings_intelliSenseMemoryLimit,
11841187
autocomplete: settings_autoComplete,
11851188
errorSquiggles: settings_errorSquiggles,
11861189
dimInactiveRegions: settings_dimInactiveRegions,

Extension/src/LanguageServer/settings.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ export class CppSettings extends Settings {
115115
public get intelliSenseEngineFallback(): string | undefined { return super.Section.get<string>("intelliSenseEngineFallback"); }
116116
public get intelliSenseCachePath(): string | undefined { return super.Section.get<string>("intelliSenseCachePath"); }
117117
public get intelliSenseCacheSize(): number | undefined { return super.Section.get<number>("intelliSenseCacheSize"); }
118+
public get intelliSenseMemoryLimit(): number | undefined { return super.Section.get<number>("intelliSenseMemoryLimit"); }
118119
public get errorSquiggles(): string | undefined { return super.Section.get<string>("errorSquiggles"); }
119120
public get inactiveRegionOpacity(): number | undefined { return super.Section.get<number>("inactiveRegionOpacity"); }
120121
public get inactiveRegionForegroundColor(): string | undefined { return super.Section.get<string>("inactiveRegionForegroundColor"); }

Extension/src/nativeStrings.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,5 +217,6 @@
217217
"cpp_probing_compiler_default_standard": "Probing compiler for default C++ language standard using command line: {0}",
218218
"detected_language_standard_version": "Detected language standard version: {0}",
219219
"unhandled_default_target_detected": "Unhandled default compiler target value detected: {0}",
220-
"unhandled_target_arg_detected": "Unhandled target argument value detected: {0}"
220+
"unhandled_target_arg_detected": "Unhandled target argument value detected: {0}",
221+
"memory_limit_shutting_down_intellisense": "Shutting down IntelliSense server: {0}. Memory usage is {1} MB and has exceeded the {2} MB limit."
221222
}

0 commit comments

Comments
 (0)