Search This Blog

Saturday, July 30, 2011

What is mscorsvw.exe and why is it eating up my CPU?


If you like this article, please click on +1 button and share with your friends.

You can find a lot of Video Tutorial at our site.
visit www.iGnani.com


Today, I suddenly found my system too very slow and most of the apps where hanging. When I checked the tasks manager, found that “mscorsvw.exe” was consuming more than 50% of the processor while my anti-virus was consuming another 30%+ which was making my system to become very sluggish.

The first thing that came to my mind when I saw anti-virus software consuming so much was that “mscorsvw.exe might be some virus” which somehow entered my system and anti-virus was trying to clean it up. But this thing went on for more than 15 min which made me worried. Did not want to find myself in the situation where I lose all my data. That is when I tried to do some research and to my surprise, the mscorsvw.exe was a tool that comes with .net framework and anti-virus was also processing to check that the output from this file.

Now before getting any further, let me give you what had happened earlier in the day. The windows update manager showed that there were some updates from Microsoft and I for one who install the updates as and when they are made available had promptly installed them. Only after that I started to face this problem.

What is mscorsvw.exe?

To keep it simple, you can consider it as a CLR Optimization service or also known as NGEN service and it also works as a NGEN worker process. While it is running, if you check the task manager you will find two instances running. While the NGEN service is the parent process, NGEN worker process does all the job.

To give you a short introduction about NGEN, it is a tool that ships with the .NET Framework can be used to compile IL code to native code when an application is installed on a user’s machine. Since the code is compiled at install time, the CLR’s JIT compiler does not have to compile the IL code at runtime, and this can improve the application’s performance.

If you don't know more about NGEN, then we have a complete article on it. Please check it out.

But why is it taking so much processing power all of a sudden?

Its not all of a sudden, but happens every time when some .NET assemblies are installed either through service pack or as an update or some other means. When mscorsvw.exe precompiles .NET assemblies in the background, it starts to consume a lot of CPU usage. Once it completes compiling, it will automatically stop.

Typically, when you install a .NET Redist, NGEN will start to process the high priority assemblies and then will wait until your computer is idle to process the low priority assemblies. Once NGEN does that it will shutdown and you won't see mscorsvw.exe. After compiling all the assemblies, you will find them executing faster.

Since it runs on a low priority process, even thought sometime you see it as consuming a lot of CPU, it does not take away from your other activity.

Is there any way to compile everything at once?

If you want NGEN to compile both high and low priority assemblies once for all and want to get rid of mscorsvw.exe from your task manager, you can just enter the following command in your command prompt:

ngen.exe executequeueditems

this will process all pending work once for all. Once this is done, the service will shutdown, as it has nothing else to do. It now disappears from your task manager.

Sometimes, when you execute the above command, it may throw an error since it man not find the ngen.exe. In such a scenario, make sure you go to the folder “C:\Windows\Microsoft.NET\Framework\v4.0.30319” or any other framework version that contains the ngen.exe and execute it from there.

Hope this gave you some idea about what is mscorsvw.exe and why is it eating your CPU.





visit www.iGnani.com



MicroMind Information Systems
#4013, K.R. Road, Banashankari II Stage,
BANGALORE - 560070
KARNATAKA, INDIA
Phone: +91 80 26762747




Technorati Tags: , , , , , , , , , ,

No comments:

Post a Comment