Increase WMI memory to support large volume of queries

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.

How to optimize WMI performance and memory usage in Windows Server. Windows Server logs WMI messages 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()Code language: JavaScript (javascript)

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'Code language: JavaScript (javascript)

And last (but not least) move the Winmgmt service to a standalone Svchost process. Default level 4 (RPC_C_AUTHN_LEVEL_PKT):

winmgmt /standalonehost

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.

Jan Reilink

Hi, my name is Jan. I am not a hacker, coder, developer or guru. I am merely an application manager / systems administrator, doing my daily thing at Embrace - The Human Cloud. In the past I worked for clidn and Vevida. With over 20 years of experience, my specialties include Windows Server, IIS, Linux (CentOS, Debian), security, PHP, websites & optimization. I blog at https://www.saotn.org.