Base solution for your next web application
Open Closed

ServiceHub.RoslynCodeAnalysisService taking too much memory #12497


User avatar
0
ajayak created

Hi,

I've migrated the solution from v13.1 to 14.2.1. Since then, I'm facing this issue. Is anyone facing the same? How did you fix it? :)

Markdown is supported
Copy & paste or drag & drop images (max 30 MB per image)

3 Answer(s)
  • User Avatar
    0
    ajayak created

    It also takes an insanely long time to build the project with the latest version. V13.1 took ~10-20 seconds.

    Markdown is supported
    Copy & paste or drag & drop images (max 30 MB per image)
  • User Avatar
    0
    oguzhanagir created
    Support Team

    Hi @ajayak

    Thank you for reporting this. We have tried to reproduce this on different machines with the latest version of an ASP.NET Zero project, but we did not observe the same high resource consumption you're experiencing. This suggests the issue might be related to your specific environment, the size of your customized solution, or cached files from the migration.

    The solutions below are highly effective for resolving this kind of performance problem. <br/> <br/> This is the most effective solution to immediately reduce high CPU and memory usage caused by ServiceHub.RoslynCodeAnalysisService.exe. The problem is that Visual Studio is trying to analyze your entire solution in real-time. By changing this setting, you tell it to only analyze the files you currently have open.

    1. In Visual Studio, go to the top menu and click Tools > Options.
    2. In the new window, navigate to Text Editor > C# > Advanced.
    3. Scroll down to the Analysis section.
    4. Uncheck the box for Enable full solution analysis.

    After applying this change, restart Visual Studio. You should see a significant drop in memory and CPU consumption. <br/> <br/> Corrupted or outdated cache files from the previous version can cause performance bottlenecks and strange behavior after a migration. Clearing them forces Visual Studio to create fresh ones.

    a) Delete the .vs folder:

    1. Close Visual Studio completely.
    2. Open your project's root folder in File Explorer.
    3. Find the hidden .vs folder. (If you can't see it, enable "Show hidden items" in File Explorer's "View" tab).
    4. Delete the entire .vs folder. Visual Studio will regenerate it the next time you open the solution.

    b) Clear the Component Model Cache:

    1. Close Visual Studio.
    2. Press Win + R to open the "Run" dialog.
    3. Type the following path and press Enter: %LOCALAPPDATA%\Microsoft\VisualStudio\
    4. Open the folder corresponding to your Visual Studio version (e.g., 17.0_... for VS 2022).
    5. Find and delete the folder named ComponentModelCache.

    Applying these two solutions will resolve the vast majority of performance issues related to the Roslyn analysis service after a project upgrade.

    If the problem persists, please do not hesitate to contact me.

    Markdown is supported
    Copy & paste or drag & drop images (max 30 MB per image)
  • User Avatar
    0
    ajayak created

    The issue was caused by too many ef migrations. Deleting old migrations fixed the memory issue

    Markdown is supported
    Copy & paste or drag & drop images (max 30 MB per image)