From 7f45727f8ab1015a7b70cf3b609d35d9d0f108c4 Mon Sep 17 00:00:00 2001 From: Max schwenk Date: Fri, 3 Oct 2025 15:18:34 -0400 Subject: [PATCH] Different approach --- _extension/package.json | 5 +++++ _extension/src/client.ts | 9 +++++++++ 2 files changed, 14 insertions(+) diff --git a/_extension/package.json b/_extension/package.json index 8aca1f4c3d..454dc60f96 100644 --- a/_extension/package.json +++ b/_extension/package.json @@ -51,6 +51,11 @@ "type": "string", "description": "Path to the @typescript/native-preview package or tsgo binary directory. If not specified, the extension will look for it in the default location.", "tags": ["experimental"] + }, + "typescript.native-preview.goMemLimit": { + "type": "string", + "description": "Set GOMEMLIMIT for the language server (e.g., '2048MiB', '4GiB'). See https://pkg.go.dev/runtime#hdr-Environment_Variables for more information.", + "tags": ["experimental"] } } } diff --git a/_extension/src/client.ts b/_extension/src/client.ts index b759501e97..fc0f4096f0 100644 --- a/_extension/src/client.ts +++ b/_extension/src/client.ts @@ -95,16 +95,25 @@ export class Client { const pprofDir = config.get("pprofDir"); const pprofArgs = pprofDir ? ["--pprofDir", pprofDir] : []; + // Get goMemLimit + const goMemLimit = config.get("goMemLimit"); + const env = goMemLimit ? { ...process.env, GOMEMLIMIT: goMemLimit } : process.env; + if (goMemLimit) { + this.outputChannel.appendLine(`Setting GOMEMLIMIT=${goMemLimit}`); + } + const serverOptions: ServerOptions = { run: { command: this.exe.path, args: ["--lsp", ...pprofArgs], transport: TransportKind.stdio, + options: { env }, }, debug: { command: this.exe.path, args: ["--lsp", ...pprofArgs], transport: TransportKind.stdio, + options: { env }, }, };