ngen.exe 高 cpu windows 10 - 組件卸載無限循環

ngen.exe 高 cpu windows 10 - 組件卸載無限循環

每當我讓電腦閒置幾分鐘時,我回來時都會看到 Process Explorer 顯示「ngen.exe」正在運行並佔用我的 4 個 cpu 中的 2 個。

問題:有沒有辦法關閉 NGEN.exe 作為背景任務?

我想(就像互聯網上的許多其他人一樣)一次性編譯所有 .net 二進位文件,而不是每次我讓計算機空閒時讓計算機“自動”這樣做。我檢查了整個微軟論壇,到目前為止沒有人對這個問題有完整的答案,而且很多人都遇到了同樣的問題。

顯然,.net 框架中的某些庫需要重新編譯,並且它會「卡住」並使 CPU 處於高電平並一遍又一遍地循環。

我剛剛遇到了同樣的問題,還有另一個線程試回答但不完整

/HKLM/SOFTWARE/Microsoft/Windows/Current Version/RUN 的 Regedit 沒有執行 .net 編譯器的項目。一定有其他原因導致 ngen.exe 觸發。

有人可以發布可能觸發此運行的其他位置嗎?

我想把它關掉,我相信很多其他人也會這麼做。我還在 Windows 10 中停用了自動更新。

更新:進程資源管理器說這是正在運行的:

「C:\ Windows \ Microsoft.NET \ Framework64 \ v4.0.30319 \ ngen.exe」卸載「C:\ WINDOWS \ assembly \ NativeImages_v4.0.30319_64 \n Microsoft.Vf‌bf9a08577#28b1 e \ Microsoft.VisualSt‌ udio.Tools.Applicati‌ons.Hosting.ni.dll" /noroot /LegacyServiceBehavior – Viktor 5 分鐘前

「C:\Windows\Microsoft.NET\Framework\v4.0.30319\ngen.exe」卸載「C:\WINDOWS\ assembly\NativeImages_v2.0.50727_32\Presentation‌Framewowotation#7fa93028119‌ ‌ork.ni .dll" /noroot /LegacyServiceBehavior – Viktor 4 分鐘前編輯

「C:\ Windows \ Microsoft.NET \ Framework64 \ v4.0.30319 \ ngen.exe」卸載「C:\ WINDOWS \ assembly \ NativeImages_v2.0.50727_64 \ Microsoft.PowerShelcCommandc. .dll" /noroot /LegacyServiceBehavior

它不斷地一遍又一遍地運行。 - 這是 Process explorer 的輸出。這非常煩人,似乎每次我離開辦公桌時都會發生這種情況。

問:看起來這些都是合法的過程。有誰知道一種方法來手動刪除這些卸載命令並完全編譯 .net 框架一次,而不是一遍又一遍地循環?

目前測試:我終止了該進程,ngentask.exe 然後轉到 Windows\Assembly 並將這些 Native Image 資料夾移至臨時目錄。如果它再次恢復,我會及時通知您。如果 NativeImages 資料夾遺失,它可能不會嘗試繼續卸載這些組件。

答案1

下載 Easy NGEN 腳本,以管理員身分執行並選擇選項 1 來執行完整的 ngen 運行:

在此輸入影像描述

這需要大量時間並完成所有掛起的 ngen 操作。此後,ngen 隊列為空,您不應再看到其他任務。

(如果連結不起作用,請將程式碼複製並貼上到txt檔案中並將其重命名為cmd):

@echo off
title Easy Ngen Runner v5 for '.NET 4.x series' by Burf

"%windir%\system32\reg.exe" query "HKU\S-1-5-19" >nul 2>&1 && (
goto :admincheckok
) || (
echo      -------
echo  *** WARNING ***
echo      -------
echo.
echo.
echo ADMINISTRATOR PRIVILEGES NOT DETECTED!
call :line
echo.
echo.
echo This script must be run with administrator privileges!
echo.
echo To do so, right click on this script and select 'Run As Administrator'
echo.
goto :fin
)

:admincheckok

"%windir%\system32\reg.exe" query "hklm\software\microsoft\Windows NT\currentversion" /v buildlabex >"%temp%\os.txt"
find /i "AMD64" <"%temp%\os.txt">nul
if %errorlevel% equ 0 (set arch=x64) else (set arch=x86)

for /f "tokens=3* delims= " %%G in ('reg query "hklm\software\microsoft\Windows NT\currentversion" /v productname') do (set winv=%%G %%H)
echo %winv%|find /i "Windows 10" >nul
if errorlevel 0 (set w10=1&for /f "tokens=3" %%G in ('reg query "hklm\software\microsoft\Windows NT\currentversion" /v UBR') do (set /a UBR=%%G))
if defined w10 (for /f "skip=2 tokens=3,4,6,7 delims=. " %%G in ('type "%temp%\os.txt"') do (set "win=%winv% %arch% Build %%G.%UBR% {%%I %%J}")
) else (
for /f "skip=2 tokens=3,4,6,7 delims=. " %%G in ('type "%temp%\os.txt"') do (set "win=Legacy %winv% %arch% Build %%G.%%H {%%I %%J}")
)
del "%temp%\os.txt"

if not exist "%windir%\Microsoft.NET\Framework\v4.0.30319" goto :notinstalled

:menu
call :title
echo.
echo 1. Run full Ngen 'update' task
echo.
echo 2. Run standard Ngen 'update' task
echo.
echo 3. Execute queued Ngen items (what Windows does in background)
echo.
echo 4. Visit the 'homepage' of Burf:
echo    (http://1drv.ms/1oVTfju)
echo.
echo 5. Information
echo.
echo 6. Exit
echo.
echo. 
echo.
choice /c 123456 /N /M "Please enter your selection> "
if errorlevel 6 goto :eof
if errorlevel 5 goto :info
if errorlevel 4 start http://1drv.ms/1oVTfju&goto :menu
if errorlevel 3 goto :ngub
if errorlevel 2 goto :ngus
if errorlevel 1 goto :nguf


:info
call :title
echo This script allows your to easily run the .NET Framework tool Ngen
echo (Native Image Generator) program.
echo.
echo The three options in the menu represent the three different methods in
echo which is can be run:
echo Menu option 1 - Recreates all images
echo Menu option 2 - Processes images that have become invalid
echo Menu option 3 - Execute items already in queue to be processed by Windows
echo.
echo Option 1 is really only beneficial after a .NET Framework or a major Windows
echo update has been installed. Option 3 executes those items already in the
echo queue, this just processes the items immediately instead of during idle
echo processor time.
echo.
echo Option 2 should be used for general use, option 1 after a .NET Framework
echo or major Windows update (including Insider Previews), and option 3 is
echo only provided for completeness of this script. It is the 'least useful'.
echo.
echo It makes sense to have queued items processed and native images updated
echo before they are actually required!
echo.
echo.
echo Press any key to return to menu...
pause >nul
goto :menu


:nguf
call :title
echo Running x86 update item task. Some 'errors' may show, this is expected.
call :line
echo.
"%windir%\Microsoft.NET\Framework\v4.0.30319\ngen.exe" update /force
if defined task (
"%windir%\Microsoft.NET\Framework\v4.0.30319\ngentask.exe" /runtimewide
)
echo.
if %arch% equ x86 (goto :nudone)
echo.
echo Now running x64 update item task. Some 'errors' may show, this is expected.
call :line
echo.
"%windir%\Microsoft.NET\Framework64\v4.0.30319\ngen.exe" update /force
if defined task (
"%windir%\Microsoft.NET\Framework64\v4.0.30319\ngentask.exe" /runtimewide
)
goto :nudone


:ngus
call :title
echo Running x86 update item task. Some 'errors' may show, this is expected.
call :line
echo.
"%windir%\Microsoft.NET\Framework\v4.0.30319\ngen.exe" update
if defined task (
"%windir%\Microsoft.NET\Framework\v4.0.30319\ngentask.exe" /runtimewide
)


echo.
if %arch% equ x86 (goto :nudone)
echo.
echo Now running x64 update item task. Some 'errors' may show, this is expected.
call :line
echo.
"%windir%\Microsoft.NET\Framework64\v4.0.30319\ngen.exe" update
if defined task (
"%windir%\Microsoft.NET\Framework64\v4.0.30319\ngentask.exe" /runtimewide
)
goto :nudone


:ngub
call :title
echo Running x86 update item task. Some 'errors' may show, this is expected.
call :line
echo.
"%windir%\Microsoft.NET\Framework\v4.0.30319\ngen.exe" executequeueditems
if defined task (
"%windir%\Microsoft.NET\Framework\v4.0.30319\ngentask.exe" /runtimewide
)


echo.
if %arch% equ x86 (goto :nudone)
echo.
echo Now running x64 update item task. Some 'errors' may show, this is expected.
call :line
echo.
"%windir%\Microsoft.NET\Framework64\v4.0.30319\ngen.exe" executequeueditems
if defined task (
"%windir%\Microsoft.NET\Framework64\v4.0.30319\ngentask.exe" /runtimewide
)
goto :nudone


:nudone
echo.
echo.
echo Done! Please note that some 'errors' may have appeared. These are, for the
echo most part, not unexpected and are not deemed critical.
echo.
goto :fin


:title
cls
echo -----------------------------------------
echo Easy Ngen Runner v5 for '.NET 4.x' series by Burf
echo -----------------------------------------
echo %win%
echo.
goto :eof


:fin
echo.
echo Press any key to exit...
pause >nul
goto :eof


:notinstalled
echo Microsoft .NET Framework 4, 4.5, 4.6, or 4.7 NOT detected. Please install before
echo using this script. If already installed, something may be 'wrong'...
goto :fin


:line
echo ____________________________________________________________________________
goto :eof

答案2

刪除註冊表中的一個鍵最終對我有用。問題是 ngen 會嘗試不斷地為註冊表中相同的損壞的 DLL 重新分配記憶體。它最終會耗盡電腦上的所有可用記憶體。

刪除鍵“\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft.NETFramework\v2.0.50727\NGenService\Roots”對我有用。停止計劃任務或終止 ngen.exe 只是臨時措施,並不能解決問題。

我無法理解微軟怎麼能讓這樣的問題持續這麼久。今天是搜尋為我找到答案的第一天。

有關該問題的更多資訊可以在這裡找到https://aloiskraus.wordpress.com/2017/12/13/the-case-of-ngen-exe-needing-50-gb-of-memory/

答案3

這對我有用,我在做了人們在網上說的所有事情后進行了病毒掃描,它立即回來了,有一個以.dll 文件形式出現的病毒,其名稱為.netframework 結果發現它是一個cpu 挖掘病毒希望有幫助

相關內容