Skip to content

Commit

Permalink
Add option to disable server gc
Browse files Browse the repository at this point in the history
  • Loading branch information
dibarbet committed May 21, 2024
1 parent 7d500f7 commit 6ce33c8
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 6 deletions.
15 changes: 10 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -1719,17 +1719,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",
Expand Down
4 changes: 3 additions & 1 deletion package.nls.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,10 @@
"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 when there is ample memory available.",
"configuration.dotnet.enableXamlTools": "Enables XAML tools when using C# Dev Kit",
"configuration.dotnet.enableXamlToolsPreview": "[Experimental] 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.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)",
"configuration.dotnet.implementType.insertionBehavior": "The insertion location of properties, events, and methods When implement interface or abstract class.",
Expand Down
6 changes: 6 additions & 0 deletions src/lsptoolshost/roslynLanguageServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -576,6 +576,12 @@ 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';
}

let childProcess: cp.ChildProcessWithoutNullStreams;
const cpOptions: cp.SpawnOptionsWithoutStdio = {
detached: true,
Expand Down
5 changes: 5 additions & 0 deletions src/shared/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -410,6 +411,9 @@ class LanguageServerOptionsImpl implements LanguageServerOptions {
public get suppressLspErrorToasts() {
return readOption<boolean>('dotnet.server.suppressLspErrorToasts', false);
}
public get useServerGC() {
return readOption<boolean>('dotnet.server.useServerGC', true);
}
}

class RazorOptionsImpl implements RazorOptions {
Expand Down Expand Up @@ -508,4 +512,5 @@ export const LanguageServerOptionsThatTriggerReload: ReadonlyArray<keyof Languag
'preferCSharpExtension',
'componentPaths',
'enableXamlTools',
'useServerGC',
];

0 comments on commit 6ce33c8

Please sign in to comment.