Sign in to follow this  
Followers 0
TalivanIBM

[SOLVED] Erase Variables

6 posts in this topic

#1 ·  Posted (edited)

I have create a little program, Gets the external IP and send it to an email, i declare many vars and i tried to erase it after some functions, but the program still took so many memroy.

The program 400k after 1 of the function 2,3 mb after 2 function 3,4 mb and stay here, declaring all the unnecessary vars to 0 the memory haven't been released.

well there is a way to free memory really, because declare the vars to 0 don't work for me

Edited by TalivanIBM

Share this post


Link to post
Share on other sites



I have create a little program, Gets the external IP and send it to an email, i declare many vars and i tried to erase it after some functions, but the program still took so many memroy.

The program 400k after 1 of the function 2,3 mb after 2 function 3,4 mb and stay here, declaring all the unnecessary vars to 0 the memory haven't been released.

well there is a way to free memory really, because declare the vars to 0 don't work for me

Run this after you make your Variables the value of "".

Func _ReduceMemory($i_PID = -1)
    If $i_PID <> -1 Then
        Local $ai_Handle = DllCall("kernel32.dll", 'int', 'OpenProcess', 'int', 0x1F0FFF, 'int', False, 'int', $i_PID)
        Local $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', $ai_Handle[0])
        DllCall('kernel32.dll', 'int', 'CloseHandle', 'int', $ai_Handle[0])
    Else
        Local $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', -1)
    EndIf

    Return $ai_Return[0]
EndFunc  ;==>_ReduceMemory
See if that relieves some it.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites

Try to create more Variables in Local, use _ReduceMemory as SmOke_N said. If you must use Globals try playing with _MemGlobalFree($hMem) (i dunno if it works good, I have never used It), also you must now that $variable=0 clears memory only for Arrays. :)


Share this post


Link to post
Share on other sites

Thank you, the function is really cool, works very fine.

Share this post


Link to post
Share on other sites

Thank you, the function is really cool, works very fine.

6 month long brain fart?

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites

6 month long brain fart?

I was occupied with other scripts..........

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  
Followers 0