Wondering why mscorsvw.exe has high CPU usage? You can speed it up.

Wondering why mscorsvw.exe has high CPU usage? You can speed it up.

Rate This
  • Comments 37

This post was written by Rich Lander, a Program Manager on the .NET Framework Team. It was written for people who want to understand why mscorsvw.exe is running on their machines and want to know how to speed it up.

Have you noticed that your machine is slowing down, and you’ve looked in Task Manager to find that mscorsvw.exe is the culprit? If so, this post will help you resolve those performance issues. Mscorsvw.exe is a component of Windows, and is otherwise known as the .NET Framework Optimization Service. It optimizes your machine to launch apps faster.

Most of the time, users do not notice mscorsvw. If you are noticing it and would like it to stop affecting your computer’s performance, we recommend that you run the script provided below. This script will cause mscorsvw to run at maximum speed in order to complete its work faster, and will likely slow down your machine during that period of time. Once the script has completed its work, it will close itself. If you notice mscorsvw again, you can re-run this script, however, we hope you don’t need to do that.

Upon clicking the link above, you will need to click through a set of dialogs asking you to open and run the script. Please do that. If you get asked which program to run the script with, choose the Windows Script Host. On Windows XP, you will need to save the script to your desktop (or another location on your computer) before running it (just double click on it).

Why do I need mscorsvw and the .NET Framework?

Millions of software developers around the world choose to write apps using the .NET Framework, which is provided by Microsoft. You’ve probably used many apps built with the .NET Framework without even knowing that. The .NET Framework includes a technology called Native Image Generator (NGEN) that makes apps launch much faster and that periodically does work to optimize your machine. You can read more about this technology in a related post: Got a need for speed? .NET apps start faster.

How can I tell if mscorsvw is running?

Task manager can tell you which apps or services are running on your machine and how much machine resources they are using. You can see mscorsvw.exe in Task Manager, highlighted below. You might see more than one reference to mscorsvw.exe in Task Manager. That’s OK and part of how it normally operates.

clip_image001

How often and when does mscorsvw run?

The .NET Framework optimization service runs at two main times:

  • When the .NET Framework is installed on your machine.
  • When the .NET Framework is serviced by Windows Update.

The first case doesn’t happen very often. The .NET Framework comes with Windows, so you often already have the .NET Framework version you need to run a given app. The second case happens more often. We update the .NET Framework a handful of times of year, usually to improve security. These updates will typically occur on a “patch Tuesday,” if you are familiar with that term.

We try to update and optimize the .NET Framework during the night (specific to each time zone), while most people are sleeping. Sometimes, it isn’t possible to do that, particularly if a machine is turned off. As a result, the .NET Framework is sometimes updated during the day, which then requires the .NET Framework Optimization Service to run during the day, too. When that happens, you might notice the service running and possibly slowing down your machine for a period of time. You might wonder why this is happening, since the .NET Framework Optimization service runs in the background.

In Windows 8, we changed the .NET Framework Optimization Service, to operate in more of a silent mode. It only does work during idle time (when you are not actively using your computer). That means that you should never notice it, even if it is operating during the day.

Can I disable or turn off mscorsvw?

We do not recommend turning off or killing the .NET Framework Optimization Service in Task Manager. It is performing an important task for your machine and will help your apps launch much faster, once it’s done that work.

However, you can speed up the .NET Framework Optimization Service. By default, it only uses one CPU core. Instead, you can tell it to get its work done as quickly as possible by using more cores (currently, it will not use more than 6). That way, it will get its work done faster, and you can get on to other things.

You can run this .NET Framework optimization speedup script (same one as provided above) to tell the .NET Framework Optimization Service to speed up. If you prefer PowerShell and have it installed, we’ve also provided a PowerShell script to speed up the optimization service. You will need to download the script to your machine, and call it from an admin PowerShell command prompt. The script needs to run under either RemoteSigned or Unrestricted PowerShell execution policy.

Note that the majority of the speed up occurs for the .NET Framework 4. If you only have the .NET Framework 2 or 3.5 installed, the speedup effect will be more minor.

Tell me more about the script. What are the mscorsvw commands?

The scripts we’ve provided are a convenience for people who don’t want to deal with a command prompt. If you prefer to use the command prompt, you can use the commands below instead. These commands depend on the version of the .NET Framework you have installed and the version of Windows that you have and whether it’s 32-bit or 64-bit.

  • .NET 4, 4.5, or 4.5.1 Preview on Windows 7 or earlier:

    c:\Windows\Microsoft.NET\Framework\v4.0.30319\ngen.exe executeQueuedItems

    On a 64-bit operating system, add:

    c:\Windows\Microsoft.NET\Framework64\v4.0.30319\ngen.exe executeQueuedItems
  • .NET 4, 4.5, or 4.5.1 Preview on Windows 8 or 8.1 Preview:

    c:\Windows\Microsoft.NET\Framework\v4.0.30319\ngen.exe executeQueuedItems
    schTasks /run /Tn "\Microsoft\Windows\.NET Framework\.NET Framework NGEN v4.0.30319"

    On a 64-bit operating system, add:

    c:\Windows\Microsoft.NET\Framework64\v4.0.30319\ngen.exe executeQueuedItems
    schTasks /run /Tn "\Microsoft\Windows\.NET Framework\.NET Framework NGEN v4.0.30319 64"
  • If you don’t have .NET 4 or later installed, but you do have .NET 2.0 or 3.5, use this command instead:

    c:\Windows\Microsoft.NET\Framework\v2.0.50727\ngen.exe executeQueuedItems

    On a 64-bit operating system, add:

    c:\Windows\Microsoft.NET\Framework64\v2.0.50727\ngen.exe executeQueuedItems

These commands assume that Windows is installed on the C drive. If that’s not the case, you can change the drive letter, or use the %windir% environment variable (ex: %windir%\Microsoft.NET\Framework\v4.0.30319\ngen.exe executeQueuedItems)

These commands must be typed from a command prompt that you have “run as administrator”. If not, you will get an error message that directs you to run the commands with administrative credentials.

Summary

The .NET Framework is installed on over a billion machines and is used to run millions of apps every day. On the .NET Framework product team, we focus on making those apps launch as quickly as possible. A big part of how we do that is by optimizing both the .NET Framework and the apps that run on it. This optimization needs to be done on your machine a handful of times a year, due to updates to the .NET Framework.

You can learn more about .NET Framework optimization in our other post on this topic: Got a need for speed? .NET apps start faster.

Leave a Comment
  • Please add 2 and 6 and type the answer here:
  • Post
  • I see three instances of mscorsvw in my task manager. What's with all the copies?

  • @dbsoccer -- In the typical case, you will see two copies of mscorsvw, but only 1 will do any real work. If you run the script we provided, or manually call ngen executeQueuedItems , then you will see it run more aggressively, using up to 1 instance per core on your machine. Usually you use threads to take advantage of extra cores, however, that's not what we did in this case (due to a set of design constraints).

  • After using the  speed up command and after finishing  all queued items I still have 2 processes running, is that normal?

  • So why does my firewall tell me it wants access to the internet all by itself if Windows Update satisfactorily patches it?  Must be safe to block then because you didn't describe it requiring network access at any point in this rather descriptive article.

  • Have yoi Developers any idea, what this piece of crap and how usefull it is on old single core machine running Win XP?? Why does this runs automatically when updating Win. It completely ruined my work, since the computer went to no speed at all.

  • @Antonio -- those processes should eventually go away. As long as they don't show that they are using any CPU, it isn't a problem.

    @curiosity -- I don't know why there is any network access. The script we provided doesn't need or use the network for anything.

    @blindmelon -- this script might not help on an older single core machine. Sorry that your machine slowed down.

  • You say "We do not recommend turning off or killing the .NET Framework Optimization Service in Task Manager. It is performing an important task for your machine and will help your apps launch much faster, once it’s done that work."

    Actually it would be great if apps launched faster, but it takes a minute or so to run a standard program like my browser because mscorsvw is taking up all the CPU time. Besides the CPUs heat up and the fan becomes very noisy. I consider this behaviour criminal for a desktop (actually laptop) machine.

    <rant>

    I have a fresh Windows 7 install on a middle-of-the-road laptop - 4GB memory, core i5 CPU. It is supposed to replace my wife's ten (perhaps twelve) years old laptop that runs Windows XP. One goal is to give her a faster PC. I think that with all the stuff that is running in the background, and the obsession of Windows to download and install at least ten patches per day, I will have a hard sell and she will want her old PC back.

    </rant>

    In short, don't tell me that mscorsvw shouldn't be turned off. Just tell me how to do it.

  • By the way, Rich, while I am frustrated with your company's products, I do appreciate your going at great lengths to explain what happens behind the scenes and offering workarounds. Sincere thanks.

  • Now I am really pissed this thing as been going for over an hour for now.. I CANT SIMPLY DO NOTHING WITH MY COMPUTER THE MEANWHILE ... it really makes me mad... what the hell is this BS I DONT WANT THIS ... MS you are  a cancer!

  • Tried the script too, still running after an hour. Tried to kill mscorsvw process, but it keeps coming back to life. You're optimizing my system? No, you are making it unusable. Typical Microsoft.

  • I'm puzzled because first we are told running the script will speed the process up, then later, lower down the blog it says that this is achieved by using more than one CPU core. Correct me if I'm wrong, but can I assume that if your computer's CPU has only one core like mine the script will have no effect?

  • reason to scrap windows and then get a real operating system ...

  • I've tried running the script above and also using the ngen.exe executeQueuedItems command run from the command prompt as an admin, but it only gets so far and then I get the following message:

    Catastophic failure <EXCEPTION FROM HRESULT: 0x8000FFFF <E_UNEXPECTED>>

    Any ideas on what is causing this / resolutions?

  • Hi,

    Is it necessary to run both 32- and 64-bit optimization commands on a 64-bit OS?  For example, do I need to run BOTH of these commands below... or will the first one be sufficient to compile both 32- and 64-bit .NET apps?

    C:\Windows\Microsoft.NET\Framework64\v4.0.30319\ngen.exe executeQueuedItems

    C:\Windows\Microsoft.NET\Framework\v4.0.30319\ngen.exe executeQueuedItems

    In case anybody needs it, I created a small PowerShell script (link below) to find the latest version of the NGEN command and run it.  I'm just not sure if I need to run the 32-bit command on a 64-bit OS.

        http://poshcode.org/5136

    thanks,

    Scott

  • How long does it take before the .NET Framework Optimization Service is complete? My machine just received the 4.5.1 version and it has been running at max CPU for over an hour.

Page 1 of 3 (37 items) 123