当前位置:   article > 正文

解决.NET Runtime Optimization Service(mscorsvw.exe)进程占用CPU过高的问题

.net runtime optimization service

在使用server系统时偶然发现系统运行速度缓慢,任务管理器检查发现一个名为.NET Runtime Optimization Service的进程正在疯狂的占用CPU,如下
在这里插入图片描述
谷歌了一下发现这个进程是在系统安装了.NET Framework 或是.NET Framework 被更新之后,触发了.NET的最佳化服务,结合我当时的情况,我确实是刚安装完.NET。。。这个服务在你安装完.NET之后还会预编译那些高优先级的assemblies,然后等到你的电脑空闲的时候再去处理那些低优先级的assemblies 。一旦它全部处理完毕,它将会终止,不再占用资源,所以这个过程是不定的,不确定他什么时间就开始占用资源,我们可以额使用一个脚本加快这个优化服务

管理员运行Powershell,执行如下脚本,即可加快这个服务的进度

链接:https://pan.baidu.com/s/1n7ysVWFxjpWWRt3nxAY3yA 提取码:buor

# Script to force the .NET Framework optimization service to run at maximum speed.

$isWin8Plus = [Environment]::OSVersion.Version -ge (new-object 'Version' 6,2)
$dotnetDir = [environment]::GetEnvironmentVariable("windir","Machine") + "\Microsoft.NET\Framework"
$dotnet2 = "v2.0.50727"
$dotnet4 = "v4.0.30319"

$dotnetVersion = if (Test-Path ($dotnetDir + "\" + $dotnet4 + "\ngen.exe")) {$dotnet4} else {$dotnet2}

$ngen32 = $dotnetDir + "\" + $dotnetVersion +"\ngen.exe"
$ngen64 = $dotnetDir + "64\" + $dotnetVersion +"\ngen.exe"
$ngenArgs = " executeQueuedItems"
$is64Bit = Test-Path $ngen64


#32-bit NGEN -- appropriate for 32-bit and 64-bit machines
Write-Host("Requesting 32-bit NGEN") 
Start-Process -wait $ngen32 -ArgumentList $ngenArgs

#64-bit NGEN -- appropriate for 64-bit machines

if ($is64Bit) {
    Write-Host("Requesting 64-bit NGEN") 
    Start-Process -wait $ngen64 -ArgumentList $ngenArgs
}

#AutoNGEN for Windows 8+ machines

if ($isWin8Plus) {
    Write-Host("Requesting 32-bit AutoNGEN -- Windows 8+") 
    schTasks /run /Tn "\Microsoft\Windows\.NET Framework\.NET Framework NGEN v4.0.30319"
}

#64-bit AutoNGEN for Windows 8+ machines

if ($isWin8Plus -and $is64Bit) {
    Write-Host("Requesting 64-bit AutoNGEN -- Windows 8+") 
    schTasks /run /Tn "\Microsoft\Windows\.NET Framework\.NET Framework NGEN v4.0.30319 64"
}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39

在这里插入图片描述
完成之后窗口会自动关闭,这时候再去观察任务管理器,发现.NET Runtime Optimization Service已经没了或者不会去过高的占用资源了,因为整个优化过程已经被加速完成了
在这里插入图片描述

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/Cpp五条/article/detail/124364
推荐阅读
相关标签
  

闽ICP备14008679号