NGen failes with out of Memory error

I have a problem that has been around for some time. A while back I installed VS 2010 and MVC along with TeamViewer and some other VS components. At some point during this install something went wrong - most likely with the MVC Tools Update install.

The install would take several hours to complete - afterwhich it was found not to be on the system - after doing the install twice - I checked the logs and found it was terminating with an error and rolling back.

Since then anything that requires .Net 2 or 4 takes an age to install.

Pattern is this

Install script kicks of NGen install command.
Memory utilisation starts to climb rapidly until it is over 3GB.
Disk drive goes bananas for 2-10 minutes
Memory released only to start again with next NGen command.
NGen log shows command followed by 'Out of Memory' followed by NGen returned 0xffffffff
Sometimes packages install correctly.
Uninstalling a package takes just as long. For some reason NGen /uninstall goes through the same process as NGen install - massive memory consumption, high disk activity. Odd given uninstall should just be a delete.

As an indication - VS2010 took 9 hours to uninstall.

I also had to disable the MSCORSVW service - as it was continually trying to recompile assemblies - each of which goes through the process above - never completes i.e. when done /update runs again because previous failed.

I have tried removing all packages back to the pre-2010 install. I have also done a repair on all .Net installs.

No joy.

Found nothing on Google - except a few similar references with the only solution to rebuild OS - which is not an option.

Any ideas as to what be causing this
LVL 61
Julian HansenAsked:
Who is Participating?
Davis McCarnConnect With a Mentor OwnerCommented:
One (or more) of your .NET installations is corrupt and it gets a bit risky fixing it; but, I have done it more than 50 times.
I would uninstall VS2010 and NGEN then try uninstalling each version of .Net.  Hopefully; they will all go away nicely; but, I'll bet one or more won't.
For those that don't , here is a cleanup tool and an article on how to use it including reinstalling .NET:
Just a wild try, try verifying your .NET installation with the Aaron Stebner tool.
Davis McCarnOwnerCommented:
Go to Add or Remove Programs in the Control Panel.  Locate the .Net entries, highlight each in turn, and, on most, if you click the support link, there will be a repair option.  If it works, great; otherwise, note that version and try all of them.
For any which could not be repaired, use the removal tool from dbruton's post to remove that version of .NET.
Then, download and reinstall those versions.
Never miss a deadline with

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

Julian HansenAuthor Commented:
Thanks for the response.

@dbrunton - downloaded and verified each of the installations - all passed

@DavisMcCarn - I had already tried this - .Net does not offer a repair. If you go to Add / Remove programs and click  Change / Remove it asks if you want to uninstall - if you say yes you get a message that .Net can't uninstall because other apps depend on it.

I used the instructions here to run the silent repair option for .Net - made no difference.
Davis McCarnOwnerCommented:
Do Start and, in the run box, type %temp%<enter>
In the window which appears should be the logs for .NET's installations which you need to inspect.  As a note, the last thing I think you wanted was a "silent" reinstall; you wanted to see the errors.

On my own PC I have .NET 2, 3, 3.5, and 4.  2 has a repair option in "Click here for support information".  All of the others have it under Change/Remove.
Julian HansenAuthor Commented:
The change option is available on 2 upwards it seems. Clicking it resulted in the following
RAM usage went up to 3.8GB from 1.1GB (see image)
The dialog in the screen shot below was on screen for more than 10 minutes while the disk did gymnastics.
ScreenshotThat was all that was displayed - after approx 12 minutes the disk quieted down and the dialog dissappeared - nothing else displayed

Same problem seems to exist after having done that.

The question is - is a .Net install just a memory hungry beast or is it just my installation.

I know for a fact there were no issues prior to the VS2010 install - the NGen logs show no Out of Memory errors prior to the install of VS2010 but they are all over the place after that. I also know that installations prior to VS2010 being installed did not take 8 hours to install and definitely did not take that length of time to uninstall.

Still can't figure out why NGen has to work so hard on an uninstall.
Julian HansenAuthor Commented:
I would uninstall VS2010
Already did that - took 9 hours - no joy.

Uninstall NGen - thought NGen was part of .Net? How do you uinstall it without removing .Net

Will try the cleanup tool.
Davis McCarnOwnerCommented:
NGen requires that .NET be up and operational......
I've requested that this question be deleted for the following reason:

Not enough information to confirm an answer.
Julian HansenAuthor Commented:
Question has not been abandoned - I am still working on the problem.

I will close this question once I have exhausted all options.
Julian HansenAuthor Commented:
I have given up on resolving this. Have acquired a new PC.

I did follow the instructions posted by Davis - and this had some limited effect in that mscorsvw stopped misbehaving - but still cannot uninstall certain apps without it taking hours.

I have awarded a B to the solution - not to the expert - as the solution partially deals with the problem but did not yield a definitive answer. It may be useful to others reading this post.

@Davis - thanks for the input and effort - appreciate it - looks like Microsoft wins this round though.
All Courses

From novice to tech pro — start learning today.