Computing the Private Working Memory of a Set from WMI Class Methods

I am using the following perl program which uses the WMI Win32_Process class to determine the 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";

      

The WMI Win32_Process class and its properties are listed on MSDN here

The problem is that it calculates the set working memory and I want to calculate the set private working memory for which the property is not defined in the linked page

Is there a way that I can compute the private working memory of a set from this class?

+3


source to share


1 answer


Change Win32_Process

to Win32_PerfRawData_PerfProc_Process

and property WorkingSetSize

to WorkingSetPrivate

. This will give you a private working set.



http://msdn.microsoft.com/en-us/library/windows/desktop/aa394323(v=vs.85).aspx

+4


source







All Articles