Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hundreds of MSBuild and ConHost instances spawning and filling up memory when trying to run web Application in Visual Studio 2015

Tags:

To give some backstory, I used to have this issue on VS2012 as well. Randomly (not all the time), when I went to run my companies Web project on IE via vs2012, it would stall for a while and ultimately fail to load. I noticed my machine would essentially struggle to do anything, and come almost to a halt.

Checking the task manager would reveal HUNDREDS, if not THOUSANDS of MSBuild.exe and Conhost.exe instance spawned, filling every possible byte of memory that they could (max 8 gigs on machine). I only had a handful of solutions which needed to be built.

I never found out the real cause, but an eventual update to VS2012 I believe curbed that issue for several months.

Fast forward to today, I am now on a machine with 16 gigs of ram and am now running VS2015 14.0.23107.

I noticed recently that the issue of the the infinitely spawning MSBuild and Conhost was back, this time filling up all of my 16 gigs of memory.

I have searched the internet as much as I can, but I have not found any topics similar to what I am experiencing.

I know that this is a 'feature' from microsoft, as referenced here:

msbuild.exe staying open, locking files

and other places.

But no one I have seen has a problem where so many MSBuilds and Conhosts spawn that every single byte of memory is consumed by them, and you are forced to restart your machine or wait until they all die (which doesn't seem to happen after any particular set amount of time).

The only environment variables I can think of when this has happened recently are:

  1. I had at least 2 instances of VS2015 running
  2. I had just got done making changes and building one solution
  3. I went to run our web application on a solution that depends on the previous one I had just built.

Does anyone else have this issue, and did you ever find the cause?

-EDIT-

Update: I am not 100% if this fixed it, but I haven't gotten it since I made these changes.

Essentially, we have two different solutions here at work. They are very similar, only difference is that one of them has way less other projects/dependencies with it.

I switch between these two solutions often, and I believe the solution config for one of them had "Debug with Extended Diagnostics" checked for at least one project.

Also, I had the build options set to do up to 8 parallel builds at the same time.

Our devops manager thinks it is possible that, some kind of switching between the solutions mixed with the parallel builds caused some kind of corruption/error which spawned thousands of MSBuilds.

We have since fixed the problem with the "Debug with Extended Diagnostics" and I have changed my build options to be only 1 parallel build and have not had the issue since.

like image 564
GenjiGlove Avatar asked Oct 22 '15 14:10

GenjiGlove


1 Answers

Interestingly enough, I had the issue where a flood of MSBuild and conhost processes started springing up and killed all my memory. In my case, it was related to my testing with time zone features. I changed my OS time zone for testing/QA of a web app and this was the result for some reason. Something with Visual Studio doesn't like on-the-fly timezone changes.

like image 87
techmell Avatar answered Oct 12 '22 23:10

techmell