dotnet / roslyn

The Roslyn .NET compiler provides C# and Visual Basic languages with rich code analysis APIs.
https://docs.microsoft.com/dotnet/csharp/roslyn-sdk/
MIT License
18.75k stars 3.99k forks source link

Huge memory usage and slow analyzers #71949

Open aldrashan opened 5 months ago

aldrashan commented 5 months ago

We've got multiple big MVC projects. For some reason, the build/analyze performance varies a lot between them. Granted, the one with the biggest issues is also the one with the most files in general.

The ServiceHub.RoslynCodeAnalysisService.exe process is currently taking up 13+GB of memory for that biggest project. It's come to the point where the ctrl + space shortcut is straight up not working anymore. Visual Studio (Enterprise 2022 Version 17.8.6) also stops colouring things, as if it doesn't recognize them, although the popover when hovering over it does work. Same issue when you press ctrl + ; to suggest imports. It just loads and loads for ages and then doesn't show any results.

Schermafbeelding 2024-02-03 201929 Schermafbeelding 2024-02-03 201843

Please suggest things I should check and details I need to add here to help dig into the problem.

CyrusNajmabadi commented 5 months ago

Please see https://github.com/dotnet/roslyn/blob/main/docs/wiki/Reporting-Visual-Studio-crashes-and-performance-issues.md. We'll need a trace to determine what's going on.

Starting with https://learn.microsoft.com/en-us/visualstudio/ide/how-to-report-a-problem-with-visual-studio?view=vs-2022 would be good. Please remember to tell it to record what you're doing as that will provide us with the necessary teachers traces.

aldrashan commented 5 months ago

I've ran the trace thingy the whole day, until the service was at 16GB again.

https://developercommunity.visualstudio.com/t/Roslyn-huge-memory-usage-and-slow-analyz/10582656?port=1025&fsid=0f222b3c-9454-4bd3-b458-d0b73e665410