55

serviceHub.Host.CLR.x86 taking a lot of memory and CPC in my Visual Studio 2017 solution. This causes Visual Studio to crash.

Any ideas on what the underlying cause is?

joe
  • 1,851
  • 3
  • 17
  • 29
  • 3
    Not strictly speaking a duplicate - but very relevant: [Can I delete ServiceHub.* in Visual Studio 2017?](https://stackoverflow.com/questions/43775861/can-i-delete-servicehub-in-visual-studio-2017) – Jim Aho Oct 11 '17 at 11:19

2 Answers2

68

The serviceHub.Host.CLR.x86 is responsible for running some processes in the background for Visual Studio 2017/2019.

Among other features, there are three Visual Studio features that run under this process and, in some cases, cause high CPU/Memory usage. They are:

  1. Full solution analysis.
  2. Live Unit Testing. (only in Visual Studio Enterprise)
  3. Code Lens. (only in Visual Studio Enterprise and Professional)

Disable these features as follows:

  1. Full solution analysis: from Tools\Options\Text Editor\C#\Advanced (please see the remarks section if your Visual Studio 19 version is 16.5 or later)
  2. Live Unit Testing: from Test\Live Unit Test
    • If the Live Unit Test is running, select Stop.
    • Go to Tools\Options\Live Unit Testing and disable the option Start unit Testing on solution load.
  3. Code Lens: from Tools\Options\Text Editor\All Languages\CodeLens
    • This feature has a lot of options. If you like Code Lens and want to keep using it, you can enable/disable each option to check which one is stressing your computer CPU/Memory.

That's it. I hope it helps.

Remarks:

In Visual Studio 2019 version 16.5, Microsoft removed the option to disable the full solution analysis.

However, you still have the option to narrow down the analysis scope to only one document. Select the option Current Document to restrict the analysis to the current document.

Marlon Assef
  • 1,441
  • 15
  • 18
  • 2
    Thanks, I faced a similar issue due to `Code Lens` – Kane May 16 '19 at 22:11
  • 3
    `Live unit testing` is only available in `Enterprise`. https://learn.microsoft.com/en-us/visualstudio/test/live-unit-testing?view=vs-2019 – Aage Oct 18 '19 at 09:15
  • 1
    I did not have enable any of the three options above and I am still getting high memory usage with serviceHub.Host.CLR, any other workaround? – luis_laurent Dec 04 '19 at 22:51
  • 3
    @luis_laurent Microsoft claims to have resolved this issue in the latest version of Microsoft Visual Studio 2019, please check the comments here https://developercommunity.visualstudio.com/content/problem/606520/servicehubhostclrx86-32-bit-high-cpu-returns-in-20.html. We use the Microsoft Visual Studio 2019 version 16.3.10 with a large codebase and we do not experience this problem anymore. I understand that for many developers update to the latest version is not an option, you should try that version to have peace of mind though. – Marlon Assef Dec 05 '19 at 04:03
  • 1
    I'm using 2019 16.4.2 and I'm getting out of memory errors with 16GB of ram that just closes visual studio completely :( – Jay Croghan Mar 06 '20 at 10:00
  • Using 2019 v16.5.4 and started to experience this issue last couple of days, moderately large solution. manually killing servicehub.roslyncodeanalysisservice32 helped with no impact (visible) on vs.net.. I'm using resharper though. – Jack0fshad0ws Apr 27 '20 at 02:38
  • In VS 2022 still seems to have a ferocious appetite for memory. Turning off all the bells and whistles helps but my project starts at 1.5GB ram then creeps up to 2GB in a short time. – Moon Waxing Nov 21 '22 at 04:24
4

This process is also executed when installing Visual Studio with the option "Install and Download" at the same time.

If the computer is not so powerful, it will consume the rest of the CPU power till gets to 100%

f4d0
  • 1,182
  • 11
  • 21