Skip to content

Commit 3c731ec

Browse files
committed
Add option to disable server gc
1 parent 3f41545 commit 3c731ec

File tree

4 files changed

+24
-6
lines changed

4 files changed

+24
-6
lines changed

package.json

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1462,17 +1462,22 @@
14621462
"default": null,
14631463
"description": "%configuration.dotnet.server.crashDumpPath%"
14641464
},
1465+
"dotnet.server.suppressLspErrorToasts": {
1466+
"type": "boolean",
1467+
"default": false,
1468+
"description": "%configuration.dotnet.server.suppressLspErrorToasts%"
1469+
},
1470+
"dotnet.server.useServerGC": {
1471+
"type": "boolean",
1472+
"default": true,
1473+
"description": "%configuration.dotnet.server.useServerGC%"
1474+
},
14651475
"dotnet.enableXamlTools": {
14661476
"scope": "machine-overridable",
14671477
"type": "boolean",
14681478
"default": true,
14691479
"description": "%configuration.dotnet.enableXamlTools%"
14701480
},
1471-
"dotnet.server.suppressLspErrorToasts": {
1472-
"type": "boolean",
1473-
"default": false,
1474-
"description": "%configuration.dotnet.server.suppressLspErrorToasts%"
1475-
},
14761481
"dotnet.projects.binaryLogPath": {
14771482
"scope": "machine-overridable",
14781483
"type": "string",

package.nls.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,10 @@
3434
"configuration.dotnet.server.trace": "Sets the logging level for the language server",
3535
"configuration.dotnet.server.extensionPaths": "Override for path to language server --extension arguments",
3636
"configuration.dotnet.server.crashDumpPath": "Sets a folder path where crash dumps are written to if the language server crashes. Must be writeable by the user.",
37-
"configuration.dotnet.enableXamlTools": "Enables XAML tools when using C# Dev Kit",
3837
"configuration.dotnet.server.suppressLspErrorToasts": "Suppresses error toasts from showing up if the server encounters a recoverable error.",
38+
"configuration.dotnet.server.useServerGC": "Configure the language server to use .NET server garbage collection. Server garbage collection generally provides better performance when there is ample memory available.",
39+
"configuration.dotnet.enableXamlTools": "Enables XAML tools when using C# Dev Kit",
40+
"configuration.dotnet.enableXamlToolsPreview": "[Experimental] Enables XAML tools when using C# Dev Kit",
3941
"configuration.dotnet.projects.enableAutomaticRestore": "Enables automatic NuGet restore if the extension detects assets are missing.",
4042
"configuration.dotnet.projects.binaryLogPath": "Sets a path where MSBuild binary logs are written to when loading projects, to help diagnose loading errors.",
4143
"configuration.dotnet.preferCSharpExtension": "Forces projects to load with the C# extension only. This can be useful when using legacy project types that are not supported by C# Dev Kit. (Requires window reload)",

src/lsptoolshost/roslynLanguageServer.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -616,6 +616,12 @@ export class RoslynLanguageServer {
616616

617617
args.push('--extensionLogDirectory', context.logUri.fsPath);
618618

619+
const env = dotnetInfo.env;
620+
if (!languageServerOptions.useServerGC) {
621+
// The server by default uses serverGC, if the user opts out we need to set the environment variable to disable it.
622+
env.DOTNET_gcServer = '0';
623+
}
624+
619625
let childProcess: cp.ChildProcessWithoutNullStreams;
620626
const cpOptions: cp.SpawnOptionsWithoutStdio = {
621627
detached: true,

src/shared/options.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ export interface LanguageServerOptions {
8080
readonly componentPaths: { [key: string]: string } | null;
8181
readonly enableXamlTools: boolean;
8282
readonly suppressLspErrorToasts: boolean;
83+
readonly useServerGC: boolean;
8384
}
8485

8586
export interface RazorOptions {
@@ -410,6 +411,9 @@ class LanguageServerOptionsImpl implements LanguageServerOptions {
410411
public get suppressLspErrorToasts() {
411412
return readOption<boolean>('dotnet.server.suppressLspErrorToasts', false);
412413
}
414+
public get useServerGC() {
415+
return readOption<boolean>('dotnet.server.useServerGC', true);
416+
}
413417
}
414418

415419
class RazorOptionsImpl implements RazorOptions {
@@ -508,4 +512,5 @@ export const LanguageServerOptionsThatTriggerReload: ReadonlyArray<keyof Languag
508512
'preferCSharpExtension',
509513
'componentPaths',
510514
'enableXamlTools',
515+
'useServerGC',
511516
];

0 commit comments

Comments
 (0)