dotnet / dotnet/vscode-csharp

Beta: Microsoft.CodeAnalysis.LanguageServer seems to leak.

Open
#5,733 59 comments 36 reactions 1 assignee Claimed by @dibarbet View on GitHub
Bug Triaged
Dominant language
TypeScript
Stars
3.1k
Forks
737
Avg merge
17h 56m
Merged PRs (30d)
21

Description

## Environment data
`dotnet --info` output:
```
.NET SDK:
Version: 7.0.100
Commit: e12b7af219

Runtime Environment:
OS Name: Windows
OS Version: 10.0.19045
OS Platform: Windows
RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\7.0.100\
```

VS Code version: `1.78.2`
C# Extension version: `v2.0.206`

## OmniSharp log
Not applicable.

## Steps to reproduce

1. Open a medium sized .NET project.
2. Work on the project for a while.

## Expected behavior
The LSP just works.

## Actual behavior

Right out of the gate, the process "Microsoft.CodeAnalysis.LanguageServer" is utilizing about 1 to 1.5 GB of ram after the initial scan of the solution is complete. After navigating through the solution a bit, as one would for a bugfix or a small feature, the memory utilization jumps to 3-4 GB.

From there, memory utilization slowly creeps up as one continues to work on the solution. My "record" so far is 9.8 GB of utilized ram. I do have a lot of RAM, and I have it so I can use it. But this creeping up in utilization is a bit concerning and suggests to me that that there is a leak.

For context, the solution consists of ~~747~~ 1245 .cs files and ~~810~~ 1344 cshtml files.

Edit: As per my comment here https://github.com/dotnet/vscode-csharp/issues/5733#issuecomment-1665550830 I can no longer say that the LSP leaks per say. But many people still report elevated memory utilization. For me personally the issue is resolved.

Edit2: See https://github.com/dotnet/vscode-csharp/issues/5733#issuecomment-1938428637 for current reproduction.

## If you experience high baseline memory

Try setting "Dotnet › Background Analysis: Analyzer Diagnostics Scope" and "Dotnet › Background Analysis: Compiler Diagnostics Scope" to `openFiles`.

You can also try setting "Max Project File Count For Diagnostic Analysis" to a lower non-zero value. The default is `1000` - I have set it to ` 250`.

```json
{
"csharp.maxProjectFileCountForDiagnosticAnalysis": 250,
"dotnet.backgroundAnalysis.compilerDiagnosticsScope": "openFiles",
"dotnet.backgroundAnalysis.analyzerDiagnosticsScope": "openFiles",
}
```

---

See also this comment for further context, if you suspect you may have a leak: https://github.com/dotnet/vscode-csharp/issues/5733#issuecomment-2261386528

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.