OmniSharp / OmniSharp/csharp-language-server-protocol

Suspected Memory Leak in Language Client

Open
#1,037 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C#
Stars
638
Forks
109
Avg merge
1m
Merged PRs (30d)
2

Description

Hello

I am investigating a suspected memory leak in the Omnisharp Language Client. When configuring the client to handle a periodic notification from an external Language Server, I consistently observe memory usage growing unbounded.

The memory profiler within VS indicates this is coming from many Newtonsoft.Json.Linq.* objects related to the OmniSharp.Extensions.JsonRpc.Server.Notification class.

These objects appear to grow even when constructing a "no-op" notification handler, which leads me to believe it may be internal to this library.

Here is how I am constructing my Language Client -

Process process = new Process(...configured for myLangServer.exe...);

LanguageClientOptions options = new LanguageClientOptions();
options.WithInput(process.StandardOutput.BaseStream)
       .WithOutput(process.StandardInput.BaseStream)
       .OnNotification("foo/bar", (MyNotification notification) =>
       {
	    Debug.Print($"Notification received.");
       });

var languageClient = OmniSharp.Extensions.LanguageServer.Client.LanguageClient.Create(options);
await languageClient.Initialize(CancellationToken.None);

I am using version 0.19.7 of the Omnisharp.Extensions.LanguageClient NuGet package. Attaching an image detailing an example of one of these Newtonsoft objects.

devenv_PaNuYVndH7

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at LanguageClient.Create, LanguageClientOptions.WithInput/WithOutput, and OnNotification using the reported 0.19.7 setup. Reproduce repeated external notifications while profiling the Newtonsoft.Json.Linq objects and trace their retention through OmniSharp.Extensions.JsonRpc.Server.Notification. Done means the leak is confirmed with a focused reproduction and its retaining path is identified for a targeted fix.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.