从 WMI 类方法计算私有工作集内存 [英] Calculating Private Working set memory from WMI class methods
问题描述
我正在使用以下 perl 程序,它使用 WMI 类 Win32_Process 来确定进程的内存使用情况
I am using the following perl program which uses WMI class Win32_Process to determine memory usage of a process
use strict;
use warnings;
use Win32::OLE qw/in/;
sub memory_usage()
{
my $objWMI = Win32::OLE->GetObject('winmgmts:\\\\.\\root\\cimv2');
my $processes = $objWMI->ExecQuery("select * from Win32_Process where Name=\'notepad.exe\'");
my $memory = 0;
foreach my $proc (in($processes))
{
$memory = $memory + $proc->{WorkingSetSize};
}
return $memory;
}
print 'Memory usage: ', memory_usage(), "\n";
WMI 类 Win32_Process 及其属性在 MSDN 这里
WMI class Win32_Process and its properties are given on MSDN here
问题是它计算工作集内存,我想计算私有工作集内存,链接页面上没有定义任何属性
Problem is that it calculates Working Set Memory and i want to calculate Private Working set memory, for which no property is defined on the linked page
有什么方法可以计算这个类的私有工作集内存吗?
Is there some way i can calculate Private Working set memory from this class?
推荐答案
将 Win32_Process
更改为 Win32_PerfRawData_PerfProc_Process
并将 WorkingSetSize
属性更改为 工作集私有
.这将为您提供私有工作集.
Change Win32_Process
to Win32_PerfRawData_PerfProc_Process
and the WorkingSetSize
property to WorkingSetPrivate
. This will give you the private working set.
http://msdn.microsoft.com/en-us/library/windows/desktop/aa394323(v=vs.85).aspx
这篇关于从 WMI 类方法计算私有工作集内存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!