How to optimize WMI performance and memory usage in Windows Server
Since I started expanding my Zabbix scripts and templates for monitoring Windows Server instances – AD, IIS and SQL Server – I found WMI was failing more and more. WMI stopped working:
WmiPrvse.exe would just crash after hitting some memory limit of 512 MB. If you run into the same issue with Windows Management Instrumentation, here is how you can increase WMI Provider Service’s memory quota. Doing so resolved my issues.
Windows Server logs WMI in
Microsoft-Windows-WMI-Activity/Operational. You can even monitor this log in Zabbix.
First, to increase WMI memory (and in my case: handles) quota, execute the following in an elevated PowerShell session:
$oWMI=get-wmiobject -Namespace root -Class __ProviderHostQuotaConfiguration $oWMI.MemoryPerHost=1024*1024*1024 $oWMI.MemoryAllHosts=2048*1024*1024 $oWMI.HandlesPerHost=6144 $oWMI.put()
This increases MemoryPerHost to 1024*1024*1024 MB (1 GB) and MemoryAllHosts to 2 GB.
- MemoryPerHost: Defines the amount of private memory that can be held by each host
- MemoryAllHosts: Defines the combined amount of private memory (in bytes) that can be held by all hosts
I chose to also increase the HandlesPerHost quota limit, from its default 4096 to 6144. Next, you can move the process to run in the COM Infrastructure group, so it starts closely after RPCSS:
Set-ItemProperty -Path HKLM:\SYSTEM\CurrentControlSet\Services\Winmgmt -Name 'Group' -Value 'COM Infrastructure'
And last (but not least) move the Winmgmt service to a standalone Svchost process. Default level 4 (RPC_C_AUTHN_LEVEL_PKT):
Reboot or restart the Windows Management Instrumentation service and you’ll notice a more reliable WMI.
the source for this information, where I found it, is in cluberti.com’s post Make WMI more robust to large volumes of queries.