Jump to content
Sign in to follow this  


Recommended Posts

Well...I know this has been done before, but I couldn't find it on the first searches, and had to bump my thread in order to get a constructive reply so I just thought I'd post it here, so that people in my situation may find it...

Func _GetUsedMemory($nPID = @AutoItPID)
    If IsString($nPID) Then $npid = ProcessExists($nPID)
    If $nPID = 0 Then Return SetError(1, 0, 0)
    $oWMIService = ObjGet("winmgmts:\\localhost\root\CIMV2")
    If @error Then Return SetError(2, 0, 0)
    $sQuery = $oWMIService.ExecQuery ("SELECT WorkingSetSize FROM Win32_Process WHERE ProcessId=" & $npid,"WQL",48)
    If IsObj($sQuery) Then
        For $sObject In $sQuery
            Return ($sObject.WorkingSetSize / 1024)

And the program I wanted it for(which was more of a curiosity than anything):

Global $max=100000
for $i=1 to $max
MsgBox(0,"","Allocating "&$max&" ints means sacrificing"&($end-$init)/1024&" KB of memory and took "&$t2&" ms")

At least I didn't post a function to calculate the area of a circle when one knows the radius (I've actually seen that)..Hope it's useful to anyone else except me :D

EDIT: Edited CODE with Smoke's version..Thankies :wacko:..Never really thought


can be neatly written as a one-liner like this:

Return SetError($error,0,0)
Edited by VicTT

[quote]Together we might liveDivided we must fall[/quote]

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Create New...