diff --git a/package.json b/package.json index 68dcc81cb..44f6c987d 100644 --- a/package.json +++ b/package.json @@ -1462,17 +1462,22 @@ "default": null, "description": "%configuration.dotnet.server.crashDumpPath%" }, + "dotnet.server.suppressLspErrorToasts": { + "type": "boolean", + "default": false, + "description": "%configuration.dotnet.server.suppressLspErrorToasts%" + }, + "dotnet.server.useServerGC": { + "type": "boolean", + "default": true, + "description": "%configuration.dotnet.server.useServerGC%" + }, "dotnet.enableXamlTools": { "scope": "machine-overridable", "type": "boolean", "default": true, "description": "%configuration.dotnet.enableXamlTools%" }, - "dotnet.server.suppressLspErrorToasts": { - "type": "boolean", - "default": false, - "description": "%configuration.dotnet.server.suppressLspErrorToasts%" - }, "dotnet.projects.binaryLogPath": { "scope": "machine-overridable", "type": "string", diff --git a/package.nls.json b/package.nls.json index 9bac1fa39..b3f1240b5 100644 --- a/package.nls.json +++ b/package.nls.json @@ -34,8 +34,9 @@ "configuration.dotnet.server.trace": "Sets the logging level for the language server", "configuration.dotnet.server.extensionPaths": "Override for path to language server --extension arguments", "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.", - "configuration.dotnet.enableXamlTools": "Enables XAML tools when using C# Dev Kit", "configuration.dotnet.server.suppressLspErrorToasts": "Suppresses error toasts from showing up if the server encounters a recoverable error.", + "configuration.dotnet.server.useServerGC": "Configure the language server to use .NET server garbage collection. Server garbage collection generally provides better performance at the expensive of higher memory consumption.", + "configuration.dotnet.enableXamlTools": "Enables XAML tools when using C# Dev Kit", "configuration.dotnet.projects.enableAutomaticRestore": "Enables automatic NuGet restore if the extension detects assets are missing.", "configuration.dotnet.projects.binaryLogPath": "Sets a path where MSBuild binary logs are written to when loading projects, to help diagnose loading errors.", "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)", diff --git a/src/lsptoolshost/roslynLanguageServer.ts b/src/lsptoolshost/roslynLanguageServer.ts index cda5f3b62..675c35d16 100644 --- a/src/lsptoolshost/roslynLanguageServer.ts +++ b/src/lsptoolshost/roslynLanguageServer.ts @@ -607,7 +607,9 @@ export class RoslynLanguageServer { args.push('--extension', extensionPath); } - if (logLevel && [Trace.Messages, Trace.Verbose].includes(this.GetTraceLevel(logLevel))) { + const isTraceLogLevel = logLevel && [Trace.Messages, Trace.Verbose].includes(this.GetTraceLevel(logLevel)); + + if (isTraceLogLevel) { _channel.appendLine(`Starting server at ${serverPath}`); } @@ -616,6 +618,15 @@ export class RoslynLanguageServer { args.push('--extensionLogDirectory', context.logUri.fsPath); + const env = dotnetInfo.env; + if (!languageServerOptions.useServerGC) { + // The server by default uses serverGC, if the user opts out we need to set the environment variable to disable it. + env.DOTNET_gcServer = '0'; + if (isTraceLogLevel) { + _channel.appendLine('ServerGC disabled'); + } + } + let childProcess: cp.ChildProcessWithoutNullStreams; const cpOptions: cp.SpawnOptionsWithoutStdio = { detached: true, diff --git a/src/shared/options.ts b/src/shared/options.ts index da2e5c78f..e511a73bd 100644 --- a/src/shared/options.ts +++ b/src/shared/options.ts @@ -80,6 +80,7 @@ export interface LanguageServerOptions { readonly componentPaths: { [key: string]: string } | null; readonly enableXamlTools: boolean; readonly suppressLspErrorToasts: boolean; + readonly useServerGC: boolean; } export interface RazorOptions { @@ -410,6 +411,9 @@ class LanguageServerOptionsImpl implements LanguageServerOptions { public get suppressLspErrorToasts() { return readOption('dotnet.server.suppressLspErrorToasts', false); } + public get useServerGC() { + return readOption('dotnet.server.useServerGC', true); + } } class RazorOptionsImpl implements RazorOptions { @@ -508,4 +512,5 @@ export const LanguageServerOptionsThatTriggerReload: ReadonlyArray