in reply to Tracking memory of a running application

Getting the info for the current process with Win32::Process::Info just requires you pass the current pid ($$) to GetProcInfo(). The hash returned (as the first element of the array) contains the following keys. I've indicated the keys that relate to the figures shown in the task manager/pslist:

perl> use Win32::Process::Info;; perl> $p = Win32::Process::Info->new;; perl> @i = $p->GetProcInfo( $$ );; perl> $h = $i[0];; perl> print "$_ => ", $h->{ $_ } || 'n/a' for keys %$h;; TerminationDate => n/a QuotaNonPagedPoolUsage => 3800 ParentProcessId => 1172 Status => n/a OSName => Microsoft Windows XP Professional|C:\WINDOWS|\Device\Harddi +sk0\Partition1 CSName => D4KG9X0J PeakPageFileUsage => 5103616 PageFileUsage => 4186112 QuotaPeakNonPagedPoolUsage => 3920 WorkingSetSize => 3887104 .......## This is the tasklist "Mem Usage" +figure. CreationDate => 1130168062 HandleCount => 103 WindowsVersion => 5.1.2600 PeakWorkingSetSize => 7254016 MaximumWorkingSetSize => 1413120 PeakVirtualSize => 142602240 WriteOperationCount => 2 SessionId => n/a PrivatePageCount => 4186112 .....## This is the tasklist "VM Size" fi +gure Owner => D4KG9X0J\Me ProcessId => 188 Caption => perl.exe CommandLine => c:\perl\bin\perl.exe -sw "c:\Perl\bin\p1.pl" OSCreationClassName => Win32_OperatingSystem Priority => 8 MinimumWorkingSetSize => 204800 CreationClassName => Win32_Process ThreadCount => 7 KernelModeTime => 0.328125 ExecutionState => n/a CSCreationClassName => Win32_ComputerSystem InstallDate => n/a WriteTransferCount => 144 OtherTransferCount => 203274 PageFaults => 2758 VirtualSize => 142602240 QuotaPagedPoolUsage => 25776 OwnerSid => S-1-5-21-756011271-1152625135-639526082-1005 ReadTransferCount => 347129 OtherOperationCount => 3358 ReadOperationCount => 171 QuotaPeakPagedPoolUsage => 25808 ExecutablePath => c:\perl\bin\perl.exe UserModeTime => 0.265625 Name => perl.exe Description => perl.exe Handle => 188

Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

Replies are listed 'Best First'.
Re^2: Tracking memory of a running application
by DrWhy (Chaplain) on Oct 24, 2005 at 20:14 UTC
    Great, thanks. PeakVirtualSize is actually what we are looking for.

    --DrWhy

    "If God had meant for us to think for ourselves he would have given us brains. Oh, wait..."

      You are aware that the PeakVirtualSize includes a lot of memory that is shared between processes?

      For example, it will include things like kernel32.dll and user32.dll which are shared by virtually (sic) every program in the system. So, whilst every perl program will use them, they will never cause additional memory* to be used when a Perl script is run as they will already be in memory.

      With the exception of a few handles and stuff


      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
      "Science is about questioning the status quo. Questioning authority".
      In the absence of evidence, opinion is indistinguishable from prejudice.
        Having worked in a Windoze environment for less than a year now, I'm still learning things all the time (such as this)! That said, I'm pretty sure this is still the measure we want. We have memory hoggy code and need to make sure it doesn't get so big it starts misbehaving; it appears that that happens when this measure exceeds 2gb.

        --DrWhy

        "If God had meant for us to think for ourselves he would have given us brains. Oh, wait..."