针对 Win32_PageFileUsage 类运行 WMI 查询会导致内存泄漏。在我的情况下,它每 5 分钟对 200 台服务器进行一次。大约 3 小时后,内存泄漏接近 10 GB。我认为这与该事实有关,即页面文件不存在。值为“0”。这是我的代码:
...
ObjectQuery pageFileUsageQuery =
new ObjectQuery("SELECT AllocatedBaseSize, CurrentUsage FROM Win32_PageFileUsage");
m_PageFileUsageSearcher = new ManagementObjectSearcher(managementScope, pageFileUsageQuery);
...
var pageFileUsageCollection = m_PageFileUsageSearcher.Get();
double currentUsage = 0;
double maxSize = 0;
foreach (ManagementBaseObject managementBaseObject in pageFileUsageCollection)
{
string result = managementBaseObject["CurrentUsage"].ToString();
currentUsage += double.Parse(result);
}
系统为 Windows Server 2008 SP2。也许有人有任何想法?