Tools

How To Stop The .NET Runtime Optimization Service From Abusing your CPU

If you have your CPU mostly busy with the .Net runtime optimization service, read on to find out how to fix it.

June 15, 2021
Vitalii Kurylo
$
HK$

If you're reading this article, you're most probably suffering from the .NET runtime optimization service consuming most of your CPU power and you want to fix this. We will list 5 methods for that, and in the end, we'll cover the theory behind this problem and fixes you shouldn't use.

Screenshot of Task Manager showing CPU loaded with .NET Runtime Optimization Service
Source: https://www.troubleshootingcentral.com/wp-content/uploads/2020/07/NET-Runtime-Optimization-Service-CPU-Usage-High-in-Task-Manager.jpg?ezimgfmt=ng:webp/ngcb11

The reason the EGO web development firm decided to put this into our blog is that some of our clients were asking us for help with this issue since we know the .NET technology and use it heavily on our projects. However, this issue doesn't have anything with the .NET development; it's more of a system malfunction.

Fix #1. Make a Malware Scan

Why: malware might run under the disguise of the .NET runtime optimization service.

Malwarebytes Scanner Screenshot
Source: Malwarebytes-Scanner.jpg

Here you'll need to use a third-party anti-malware tool of your choice, so we can't provide precise instruction. In most cases, the interface will have a big notable button to launch the scan. Once it finds malware, it will suggest the best action for it.

If you're not sure about this method and thus don't want to purchase the software you might not need, check out free Avast and Malwarebytes tools. N.B.: we're not affiliated with any of those.

Fix #2. Speed up the .NET Service

Why: there's a Windows-native tool called ngen.exe that can improve the performance of the .Net runtime optimization service by precompiling the cache for it (by default, it is compiled on the go and that might be the bottleneck of the problem).

Command prompt screenshot with the CD command entered
Source: EGO web application development company

The following instruction explains how to execute one command in Command Prompt.

Step 1.

Open the Command Prompt. Find it by searching for "cmd" in the search box.

Step 2.

Proceed to the location of the ngen.exe file. If your system is installed on the C drive, here's the command for it:

If you have a 32-bit Windows:

cd C:\Windows\Microsoft.NET\Framework\v4.0.30319

If you have a 64-bit Windows:

cd C:\Windows\Microsoft.NET\Framework64\v4.0.30319

The "cd" command stands for "change directory (to)".

Step 3.

Now you can execute the ngen.exe tool by typing the next command:

ngen.exe executequeueditems

If you bump into the "ngen.exe not found" error, download and install the latest version of Microsoft Framework applicable for your OS version.

If this helps, you should notice decreased CPU usage in the Task Manager.

Fix #3: Use Microsoft's Script

Why: the script does virtually the same as the command from fix #2, but if you don't fancy the command line like our web development company clients, you'll find this method easier.

GitHub Screenshot showing the location of the Raw button
Source: EGO

Step 1.

Proceed to the official GitHub page of the script: https://github.com/Microsoft/dotnet/blob/master/tools/DrainNGENQueue/DrainNGenQueue.wsf

Step 2.

Find the Raw button. Right-click it and select "Save link as…" to save it on your drive as a Windows Script file (.wsf).

Step 3.

Launch the file. The app responsible for opening it is Windows Script Host.

Again, if it helps, your CPU power shouldn't be loaded mostly with the .Net runtime optimization service anymore.

Fix #4: Restart the Nvidia Telemetry Service

Why: relaunching the service might help get rid of the corrupted data that was causing the .NET runtime optimization service to work too slow.

Note: this fix works only for the owners of dedicated NVIDIA video cards.

Step 1.

Search "services" in Windows 10 Search box. Click on the Services icon to Open Service Manager.

If you have an older version of Windows, press Windows Key + R to open the Run window and type in "services.msc" to launch Service Manager there.

Windows 10 screenshot of the search results for the Services query
Source: EGO

Step 2.

Locate NVIDIA Telemetry Container service. Double-click it to open the property window.

Step 3.

Click the Stop button and then Start.  

Settings for Nvidia Telemetry Container (General Tab)
Source: start_service.png

Now, with the older Windows version, you might get an "Error 1079".

In this case, get back to the property window and proceed to the Log On tab. There, you'll need to press the Browse… button and under the "Enter the object name to select" enter your account's name. Then, press Check Names and wait until the name is available. Press OK, type in the password if prompted, and after that repeat Step 3.

Settings for Nvidia Telemetry Container (Log On Tab)
Source: log_on.png

Fix #5: Perform a Clean Boot

Why: in case a third-party app causes the issue, you can boot Windows without any third-party services launching on system startup.

As a performance testing company, we’d like to note here that this is not a fix but rather a way to find a particular service consuming your CPU power and do something with it (stop it or update the corresponding software).

Step 1.

Type in and launch "msconfig" in the search box.

Windows 10 Search results for the "msconfig" query
Source: EGO

Step 2.

Proceed to the Services tab. Tick the "Hide all Microsoft services" checkbox. That will leave only third-party services on the list. Disable all of them by pressing "Disable All".

Syste, Configuration window screenshot
Source: EGO

Step 3.

If asked to reboot, refuse and restart later. Now open Task Manager. You can do it in a few ways:

  1. Right-click the taskbar and click Task Manager.
  2. Launch msconfig.exe again, proceed to the Startup tab and select "Open Task Manager".
  3. Search for Task Manager in the Search box.
Windows 10 Screenshot of Task Manager
Source: EGO

Step 4.

In the Task Manager, find the apps labeled as having "high impact" in the Startup Impact column and disable them via a right-click menu.

Step 5.

Reboot. With these settings, it’s going to be a clean boot mode. If the problem is gone, you can enable the startup tasks one by one to be sure which service is exactly guilty of draining your CPU power. If you find it, you can turn on the third-party services you disabled during Step 2 all at once. If not, turn them on one by one to find the CPU-abusing service among them.

Once you find it, take an appropriate action: remove, update, replace it with an alternate software or simply keep it disabled.

Information Behind the Issue

.NET Runtime Optimization Service (launched from the Mscorsvw.exe file) recompiles its libraries for better system performance. Microsoft states it is expected to run only when your PC is idle and requires a few minutes at most. However, in real life, things appear to be different.

As stated above, there are many possible reasons for that. It might be malware disguising as a .NET runtime optimization service. Another possible reason is a third-party app corrupting the files this service needs to operate. That’s why there is no universal fix to it.  

Fixes You Shouldn't Use

When clients have this problem, they often ask the guys at our design and development company how to stop and remove this .NET runtime optimization service for good.

Indeed, one simple way to address the issue is to prevent Windows from launching this service in the first place. This is the last resort, a method we suggest using only if any other fix didn't work. The whole purpose of the .NET runtime optimization service is to help Windows run faster, which is something you wouldn't want to refuse.

However, if you want to stop the service, proceed to the Services app again, find Net Runtime Optimization Service there and open its Properties via right-click. There, changed the Start Type to Disabled or Manual.

You can also find a registry hack on the Internet that suggests finding the 'ClearPageFileAtShutDown' parameter in Regedit and changing its value to 1. This is just plain wrong since it will remove all files the .NET service has already optimized every time Windows shuts down. On the next start, the .NET runtime optimization service will start its work from the very beginning, thus making your computer even slower than before.

LIKE THIS ARTICLE? Help us SPREAD THE WORD.

More Articles

Back to blog