Windows 2008 R2 – WMI Quota issue caused by either a WMI leak or an application overallocating WMI memory
I- Default WMI memory quotas for Windows 2008 R2:
Memory Per Host: 536870912
Handles Per Host: 4096
Memory All Hosts: 1073741824
Process Limit All Hosts: 32
Threads Per Host: 256
To check what is the current ones on any Windows 2003 and up servers, you can use the following script, and pipe one or more servers on the function from the following script:
#Disclaimer : The below script takes a file with server names as pipeline input.
#You can write a better function with more time with parameters, error control, etc...
#
#How to use :
#1- run the script to load the function
#2- create a text file with server names for which we want to check the WMI quotas
#3- Launch Get-Content C:tempServerNames.txt | Check-AllWMIQuotas
Function Check-AllWMIQuotas {
Begin {
Write-Host "Beginning to process servers from the pipeline"
}
Process {
#Load the __ProviderHostQuotaConfiguration class from the root namespace
$objWMI=get-wmiobject -ComputerName $_ -Namespace root –Class __ProviderHostQuotaConfiguration
Write-Host "----------- Checking Server $_ ------------"
Write-host "Memory Per Host: "$objWMI.MemoryPerHost
Write-Host "Handles Per Host: "$objWMI.HandlesPerHost
Write-Host "Memory All Hosts: "$objWMI.MemoryAllHosts
Write-Host "Process Limit All Hosts: "$objWMI.ProcessLimitAllHosts
Write-Host "Threads Per Host: "$objWMI.ThreadsPerHost
}
End {
Write-Host Finished !
}
}
II- Either monitor WMIPrsve process using Perfmon (ProcessPrivate Bytes of all WMI processes (WmiPrvSE*)) to see if memory is skyrocketting and/or take a dump of the WmiPrvSE process to see which application is using all WMI memory from the allocated quota.
See https://blogs.technet.com/b/kevinholman/archive/2010/06/09/wmi-leaks-memory-on-server-2008-r2-monitored-agents.aspx for some détails.
III- Or if it appears an application needs more WMI memory than allowed by the default quotas, raise the quotas.
Usually doubling the “Memory Per Host” property is enough. But I usually try first by doubling all properties.
You can either use WBEMTEST to change the WMI quota, or use Powershell along with GWMI (or Get-WMIObject) to change these on several servers if needed.
Here is a sample script :
#Disclaimer : The below script takes a file with server names as pipeline input.
#You can do a better function with more time with parameters, error control, etc...
#How to use :
#1- run the script to load the function (copy/paste in a .PS1 file or copy/paste it directly on a Powershell window)
#2- create a text file with server names for which we want to change the WMI quotas
#3- Launch Get-Content C:tempServerNames.txt | Double-AllWMIQuotas
Function Double-AllWMIQuotas {
Begin {
Write-Host "Beginning to process servers from the pipeline"
Write-Host "Storing Windows 2008 R2 default"
$defaultMemoryPerHost=536870912
$defaultHandlesPerHost=4096
$defaultMemoryAllHosts=1073741824
$defaultProcessLimitAllHosts=32
$defaultThreadsPerHost=256
}
Process {
#Load the __ProviderHostQuotaConfiguration class from the root namespace
$objWMI=get-wmiobject -ComputerName $_ -Namespace root -Class __ProviderHostQuotaConfiguration
#Usually, the below line should be enough, but I recommend to double all values
$objWMI.MemoryPerHost=$defaultMemoryPerHost*2
#Again, usually the below lines are optional but best practices to be sure we won’t have any Out Of Memory error.
$objWMI.HandlesPerHost=$defaultHandlesPerHost*2
$objWMI.MemoryAllHosts=$defaultMemoryAllHosts*2
Comments
- Anonymous
November 21, 2016
Thanks a lot for sharing this information. One hint, the second script was not running at my servers (2008R2) before i added the following lines: $objWMI.Put() } End { ... Write-Host Finished ! } }