Windows

如何查找各個 Windows 服務的記憶體使用情況?

  • March 16, 2020

任務管理器顯示 svchost.exe 的整體記憶體使用情況。有沒有辦法查看單個服務的記憶體使用情況?


請注意,這類似於svchost.exe 上的細粒度性能報告

有一種簡單的方法可以獲取您要求的資訊(但它確實需要對您的系統稍作改動):

拆分每個服務以在其自己的 SVCHOST.EXE 程序中執行,並且消耗 CPU 週期的服務將在任務管理器或程序資源管理器中輕鬆可見(“=”後的空格是必需的):

SC Config Servicename Type= own

在命令行視窗中執行此操作或將其放入 BAT 腳本中。需要管理權限,並且需要重新啟動電腦才能生效。

可以通過以下方式恢復原始狀態:

SC Config Servicename Type= share

範例:使 Windows Management Instrumentation 在單獨的 SVCHOST.EXE 中執行:

SC Config winmgmt Type= own

這種技術沒有不良影響,除了可能會稍微增加記憶體消耗。除了觀察每個服務的 CPU 使用率之外,它還可以很容易地觀察每個服務的頁面錯誤增量、磁碟 I/O 讀取率和磁碟 I/O 寫入率。對於 Process Explorer,菜單 View/Select Columns:選項卡 Process Memory/Page Fault Delta,選項卡 Process Performance/IO Delta Write Bytes,選項卡 Process Performance/IO Delta Read Bytes。


在大多數係統上,只有一個具有大量服務的 SVCHOST.EXE 程序。我使用了這個序列(可以直接粘貼到命令行視窗中):

rem  1. "Automatic Updates"
SC Config wuauserv Type= own

rem  2. "COM+ Event System"
SC Config EventSystem Type= own

rem  3. "Computer Browser"
SC Config Browser Type= own

rem  4. "Cryptographic Services"
SC Config CryptSvc Type= own

rem  5. "Distributed Link Tracking"
SC Config TrkWks Type= own

rem  6. "Help and Support"
SC Config helpsvc Type= own

rem  7. "Logical Disk Manager"
SC Config dmserver Type= own

rem  8. "Network Connections"
SC Config Netman Type= own

rem  9. "Network Location Awareness"
SC Config NLA Type= own

rem 10. "Remote Access Connection Manager"
SC Config RasMan Type= own

rem 11. "Secondary Logon"
SC Config seclogon Type= own

rem 12. "Server"
SC Config lanmanserver Type= own

rem 13. "Shell Hardware Detection"
SC Config ShellHWDetection Type= own

rem 14. "System Event Notification"
SC Config SENS Type= own

rem 15. "System Restore Service"
SC Config srservice Type= own

rem 16. "Task Scheduler"
SC Config Schedule Type= own

rem 17. "Telephony"
SC Config TapiSrv Type= own

rem 18. "Terminal Services"
SC Config TermService Type= own

rem 19. "Themes"
SC Config Themes Type= own

rem 20. "Windows Audio"
SC Config AudioSrv Type= own

rem 21. "Windows Firewall/Internet Connection Sharing (ICS)"
SC Config SharedAccess Type= own

rem 22. "Windows Management Instrumentation"
SC Config winmgmt Type= own

rem 23. "Wireless Configuration"
SC Config WZCSVC Type= own

rem 24. "Workstation"
SC Config lanmanworkstation Type= own

rem End.

引用自:https://serverfault.com/questions/12278