Memory Use

Get help with using AutoHotkey and its commands and hotkeys
Peabianjay
Posts: 47
Joined: 07 Nov 2015, 22:50

Memory Use

19 Dec 2015, 14:41

I wanted to look at my memory use, so I found a few example functions & such that people seem to think are great.....'cept, they're not working for me.
They all report zero memory, for any/all processes.

Primarily, I'm interested in the amount of memory in use by the script I'm working on.

This one, by Senenity: https://autohotkey.com/board/topic/3320 ... ntry210784
Msgbox % GetProcessMemoryInfo( "chrome.exe" ) ==> zero!?

Or this one: (sorry, forgot where I got it, so can't credit the author)

Code: Select all

GetProcessMemory_All(ProcName)
{
    Process, Exist, %ProcName%
    pid := Errorlevel

    ; get process handle
    hProcess := DllCall( "OpenProcess", UInt, 0x10|0x400, Int, false, UInt, pid )

    ; get memory info
    PROCESS_MEMORY_COUNTERS_EX := VarSetCapacity(memCounters, 44, 0)
    DllCall( "psapi.dll\GetProcessMemoryInfo", UInt, hProcess, UInt, &memCounters, UInt, PROCESS_MEMORY_COUNTERS_EX )
    DllCall( "CloseHandle", UInt, hProcess )

    list := "cb,PageFaultCount,PeakWorkingSetSize,WorkingSetSize,QuotaPeakPagedPoolUsage"
          . ",QuotaPagedPoolUsage,QuotaPeakNonPagedPoolUsage,QuotaNonPagedPoolUsage"
          . ",PagefileUsage,PeakPagefileUsage,PrivateUsage"

    n := 0
    Loop, Parse, list, `,
    {
        n += 4
        SetFormat, Float, 0.0 ; round up K
        this := A_Loopfield
        this := NumGet( memCounters, (A_Index = 1 ? 0 : n-4), "UInt") / 1024

        ; omit cb
        If A_Index != 1
            info .= A_Loopfield . ": " . this . " K" . ( A_Loopfield != "" ? "`n" : "" )
    }

    Return "[" . pid . "] " . pname . "`n`n" . info ; for everything
}

Return to “Ask For Help”

Who is online

Users browsing this forum: Bing [Bot], Google [Bot], Jovannb, Lecso0522, mikeyww and 51 guests