Reputation: 2669
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 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?
Upvotes: 4
Views: 8384
Reputation: 744
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
Upvotes: 5