Closed vsfeedback closed 3 years ago
@sharwell's analysis:
looks like ~6GB held by Analyzer.Utilities.SymbolDisplayStringCache. I'm guessing the keys of the concurrent collection need to be changed to
(WeakReference<ISymbol> symbol, int hash)
, and/or switch to CWT.
I'll let @dotpaul decide how to tackle this issue, SymbolDisplayStringCache
is used by security analyzers.
@mavasani just out of curiosity, what is "CWT"?
@mavasani just out of curiosity, what is "CWT"?
Will this fix be made available as a hotfix? I'm constantly having to restart VisualStudio multiple times a day.
@udlose as a workaround you can create an EditorConfig file at the root of your repo and turn off the security rules by adding the following configuration entry. You can read more about it here
[*.cs]
dotnet_analyzer_diagnostic.category-Security.severity = none
Thanks for the quick turnaround! Will this be released as an update to VisualStudio in the next update?
@udlose as a workaround you can create an EditorConfig file at the root of your repo and turn off the security rules by adding the following configuration entry. You can read more about it here
[*.cs] dotnet_analyzer_diagnostic.category-Security.severity = none
@mavasani , @dotpaul I made the suggested change while waiting for a fix and still saw a leak. I have a dump file to share - it's zipped size is just under 1GB. Where should I upload it?
@udlose You can submit it through the Report a Problem tool in Visual Studio.
I've created a new VS Feedback Item here along with the memory dump - https://developercommunity.visualstudio.com/t/Memory-leak-in-ServiceHubRoslynCodeAnal/1411739
@mavasani The workaround described above did not appear to have any impact on the scenario.
is there any update on this?
This is fixed by #5071, but @mavasani would need to provide information about which release first contains the fix.
@mavasani could you please let me know what release of VS this fix will be included in?
@mavasani bump. This is a productivity killer as the proposed workaround is not working. I have to constantly restart VS throughout the day. Can you let me know what version of VS this is fixed in? TIA
@udlose This fix ships with an analyzer package and/or the .NET SDK, as opposed to shipping as part of Visual Studio. @mavasani or @jmarolf may be able to associate the pull request above with specific packages/versions.
@udlose this is in the latest .NET SDK preview and will be in the .NET 6 SDK (you can use newer SDKs to build older projects)
@jmarolf we are nowhere close to being ready to move from .NET 5 to .NET 6 (even once it is formally released). Can't this be backported to .NET 5?
@udlose I think you could use the analyzers from NuGet instead of from the SDK.
as @Youssef1313 says, you can reference these nuget packages directly instead of letting them come implicitly from the SDK if you cannot wait
Is there a preview available for the nuget? The latest version I see is 5.0.3 from January 2021 - https://github.com/dotnet/roslyn-analyzers/releases/tag/5.0.3
@udlose Preleases are here
@jmarolf , @sharwell , @mavasani
So this problem is still not fixed in the latest Microsoft.CodeAnalysis.NetAnalyzers
v6.0.0-rc1.21362.2 (built 7/12/21). I've installed the above nuget and still have the memory and CPU spiking for ServiceHub.RoslynCodeAnalysisService.exe
. I captured a 2.7 GB memory dump of ServiceHub.RoslynCodeAnalysisService.exe
. Where should I upload this memory dump since this issue has been moved to GitHub from the VS Feedback Forum. The zipped memory dump is 571 MB and too big to post here.
Here is a snippet from my .csproj to see what I have enabled:
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<EnableNETAnalyzers>true</EnableNETAnalyzers>
<RunAnalyzersDuringBuild>true</RunAnalyzersDuringBuild>
</PropertyGroup>
<PropertyGroup>
<AnalysisMode>AllEnabledByDefault</AnalysisMode>
</PropertyGroup>
I hava same problem ,its will take 3-4gb memory when im use 4-5 hours. and when im use 2days. my pc will Downtime.vs take my 95% memory. I must reboot my PC to solve.
@udlose You can create a new VS feedback via Report a Problem and attach the heap dump to that. Feel free to mention me and/or link to this issue.
@sgf We would need a separate heap dump from your scenario to start the investigation. It can be filed as a separate feedback from all the others.
I also have this problem and it is really killing productivity. Actually thought it was a Windows11 thing, because i haven't seen it in windows10, but now I have it every day :-\
@conteabhp Can you follow the suggestion in https://github.com/dotnet/roslyn-analyzers/issues/5059#issuecomment-924117919 ?
I have tried adding a .editorconfig and get this error
@Youssef1313
I get the above error when trying to add the .editorconfig file.
We are running Core 3.1
I have tried adding a .editorconfig and get this error
@conteabhp That seems a completely different issue. For this one, I think you can open an issue in dotnet/roslyn
@conteabhp Can you follow the suggestion in #5059 (comment) ?
@Youssef1313 I am not sure what you want me to do. If I press the link to the answer you are refering i get this:
@udlose You can create a new VS feedback via Report a Problem and attach the heap dump to that. Feel free to mention me and/or link to this issue.
@sgf We would need a separate heap dump from your scenario to start the investigation. It can be filed as a separate feedback from all the others.
@conteabhp Yes exactly. You need to report the issue using "Send feedback" in Visual Studio.
@Youssef1313 allready done that
Problem still exists. RoslyCodeAnalysisService.exe drains all of RAM it could get. It makes it impossible not just to use Visual Studio but whole my system as it, i repeat, drains absolutly all of memory it can. As a result i get black screen blinking, complete system freeze(after 3-5 mins of running visual studio), mouse freezing, cant even open Windows Task manager, all chrome tabs crashed due to memory lack
I made a clean installation of last Visual Studio on my Windows 10 machine that has 32 Gb or RAM, Ryzen 7 5800x and Samsung EVO+ SSD. I can open up to 300 chrome tabs with active around 30+, launch couple of virtual machines, same time launch Opera + Firefox with 10+ tabs open, 2 IDES - JetBrains and Visual Studio Code and all is running ultra fast, but openning just one blank Visual Studio with that Roslyn Bug Software breaks everything.
I dont even Build or Debug Solution, just open it, and after 3-5 mins 25 GiGaBytyes of RAM is drained !!!
Solution is a corporate DSP system containing of 10 projects. With an API of around 10-12 groups with 2-3 requets each - not so huge at all !!!!
I tried:
System Info:
Windows 10
Microsoft Visual Studio Community 2022 Version 17.2.5 VisualStudio.17.Release/17.2.5+32616.157 Microsoft .NET Framework Version 4.8.04084
Installed Version: Community
.NET Core Debugging with WSL 1.0 .NET Core Debugging with WSL
ASP.NET and Web Tools 2019 17.2.393.26812
Azure App Service Tools v3.0.0 17.2.393.26812
Azure Functions and Web Jobs Tools 17.2.393.26812
C# Tools 4.2.0-4.22281.5+8d3180e5f00d42f0f0295165f756f368f0cbfa44 C# components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.
Common Azure Tools 1.10
Microsoft JVM Debugger 1.0
NuGet Package Manager 6.2.1
Razor (ASP.NET Core) 17.0.0.2218101+885a343b00bcab620a90c1550c37dafd730ce984
SQL Server Data Tools 17.0.62204.01010
TypeScript Tools 17.0.10418.2001
Visual Basic Tools 4.2.0-4.22281.5+8d3180e5f00d42f0f0295165f756f368f0cbfa44
Visual F# Tools 17.1.0-beta.22274.4+211fd760c2315d73cfa0d375fe64abb346bc1096
Visual Studio IntelliCode 2.2
Questions:
@AntonGrekov The original issue was already fixed. You might be experiencing a different issue. Can you follow https://docs.microsoft.com/en-us/visualstudio/ide/how-to-increase-chances-of-performance-issue-being-fixed?view=vs-2022#slowness-and-high-cpu-issues ?
I agree, I also still have massive problems using visual studio because of it’s consumption of all computer resources. I have around 100% cpu, 100% ram and between 50-60% disk access.
Working with this is impossible, and there is not much help from Microsoft 😕
Maybe it is time considering Rider or other UI….. not what I want but VS is making it very difficult to do my job on a daily basis
So I completely agree with you, we need a solution for this!
Hent Outlook til iOShttps://aka.ms/o0ukef
Fra: Anton Grekov @.> Sendt: Saturday, July 9, 2022 2:21:04 PM Til: dotnet/roslyn-analyzers @.> Cc: Bo Høirup Pedersen @.>; Mention @.> Emne: Re: [dotnet/roslyn-analyzers] Memory leak in ServiceHub.RoslynCodeAnalysisService.exe (#5059)
Problem still exists. RoslyCodeAnalysisService.exe drains all of RAM it could get. It makes it impossible not just to use Visual Studio but whole my system as it, i repeat, drains absolutly all of memory it can. As a result i get black screen blinking, complete system freeze(after 3-5 mins of running visual studio),
I made a clean installation of last Visual Studio on my Windows 10 machine that has 32 Gb or RAM, Ryzen 7 5800x and Samsung EVO+ SSD. I can open up to 300 chrome tabs with active around 30+, launch couple of virtual machines, same time launch Opera + Firefox with 10+ tabs open, 2 IDES - JetBrains and Visual Studio Code and all is running ultra fast, but openning just one blank Visual Studio with that Roslyn Bug Software breaks everything.
I dont even Build or Debug Solution, just open it, and after 3-5 mins 25 GiGaBytyes of RAM is drained !!! Solution is a corporate DSP system contains of 10 projects. With an API of around 10-12 groups with 2-3 requets each - not so huge at all !!!!
I tried:
System Info: Windows 10 Microsoft Visual Studio Community 2022 Version 17.2.5 VisualStudio.17.Release/17.2.5+32616.157 Microsoft .NET Framework Version 4.8.04084
Installed Version: Community
.NET Core Debugging with WSL 1.0 .NET Core Debugging with WSL
ASP.NET and Web Tools 2019 17.2.393.26812 ASP.NET and Web Tools 2019
Azure App Service Tools v3.0.0 17.2.393.26812 Azure App Service Tools v3.0.0
Azure Functions and Web Jobs Tools 17.2.393.26812 Azure Functions and Web Jobs Tools
C# Tools 4.2.0-4.22281.5+8d3180e5f00d42f0f0295165f756f368f0cbfa44 C# components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.
Common Azure Tools 1.10 Provides common services for use by Azure Mobile Services and Microsoft Azure Tools.
Microsoft JVM Debugger 1.0 Provides support for connecting the Visual Studio debugger to JDWP compatible Java Virtual Machines
NuGet Package Manager 6.2.1 NuGet Package Manager in Visual Studio. For more information about NuGet, visit https://docs.nuget.org/
Razor (ASP.NET Core) 17.0.0.2218101+885a343b00bcab620a90c1550c37dafd730ce984 Provides languages services for ASP.NET Core Razor.
SQL Server Data Tools 17.0.62204.01010 Microsoft SQL Server Data Tools
TypeScript Tools 17.0.10418.2001 TypeScript Tools for Microsoft Visual Studio
Visual Basic Tools 4.2.0-4.22281.5+8d3180e5f00d42f0f0295165f756f368f0cbfa44 Visual Basic components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.
Visual F# Tools 17.1.0-beta.22274.4+211fd760c2315d73cfa0d375fe64abb346bc1096 Microsoft Visual F# Tools
Visual Studio IntelliCode 2.2 AI-assisted development for Visual Studio.
Questions:
[2022-07-09 14_37_02-Диспетчер задач]https://user-images.githubusercontent.com/44285258/178105522-6bea4fe9-1160-4f66-8262-a0d5d4cac5bf.png
— Reply to this email directly, view it on GitHubhttps://github.com/dotnet/roslyn-analyzers/issues/5059#issuecomment-1179534399, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ASMVSATBBTAUA3ZEG3NNLA3VTFVDBANCNFSM43N7LJRA. You are receiving this because you were mentioned.Message ID: @.***>
@AntonGrekov
I faced the same problem as you after changed to VS2022. I found that RoslynCodeAnalysis run as seperated process and consume memory as much as it can.
I solve the issues, after followed this link: https://stackoverflow.com/questions/72627558/vs-2022-high-ram-and-cpu-issue-with-rosylin-code-analysis
Hope this help.
@AntonGrekov
I faced the same problem as you after changed to VS2022. I found that RoslynCodeAnalysis run as seperated process and consume memory as much as it can.
I solve the issues, after followed this link: https://stackoverflow.com/questions/72627558/vs-2022-high-ram-and-cpu-issue-with-rosylin-code-analysis
Hope this help.
That solved my problem. Thank you
@AntonGrekov Thanks for sharing I have done 2 things that have made a massive difference in the resources consumed by VS.
1. We had about 1400 migrations in our solution, and after I merged them into one migration the consumed resources dropped a lot. And as an extra bonus, our buildtime is reduced by ~50%
2. I did what you described and have not had any issues with the Roslyn process since.
So fingers crossed that no new issues appears for a while :D
Still an issue in 2023. Occurs whenever VS switched from Debug to Release configuration and dev edits some code in Release configuration. Solution is pretty small, 15 projects with tests. Includes DB projects, ASP.NET + Webforms, and esproj for frontend
Microsoft Visual Studio Enterprise 2022 (64-bit) - Current Version 17.6.5 Microsoft .NET Framework Version 4.8.09032
still an issue in 2024, in windows 11, i just build and it kills my cpu used to be ok a few months ago, now every time i build, memory usage goes up... also, errors keep showing in "build + intelsense", even when code is ok, maybe related to leak?
Note that this issue relates only to a single, highly-specific item filed by one user. In order to start the investigation for any other user, a new issue would need to be filed. To avoid confusion, I'm going to lock this issue since there is no more work to be done with it.
This issue has been moved from a ticket on Developer Community.
ServiceHub.RoslynCodeAnalysisService.zip [severity:I'm unable to use this version] I recently removed the FxCopAnalyzers as recommended here: https://docs.microsoft.com/en-us/visualstudio/code-quality/migrate-from-fxcop-analyzers-to-net-analyzers and added the following to my .csproj file:
AllEnabledByDefault
I have a GlobalSuppressions.cs with a handful of suppressions. I am using VS 16.9.4.
After updating I started to noticed a large amount of memory eaten up by ServiceHub.RoslynCodeAnalysisService.exe. I've attached a dump file of ServiceHub.RoslynCodeAnalysisService.exe.
Original Comments
Feedback Bot on 4/22/2021, 08:08 AM:
We have directed your feedback to the appropriate engineering team for further evaluation. The team will review the feedback and notify you about the next steps.
Feedback Bot on 4/23/2021, 01:14 AM:
This issue is currently being investigated. Our team will get back to you if either more information is needed, a workaround is available, or the issue is resolved.
Original Solutions
(no solutions)