Jump to content

[SOLVED] Erase Variables


Recommended Posts

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
Link to comment
Share on other sites

  • Moderators

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.

Link to comment
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. :)

Link to comment
Share on other sites

  • 6 months later...
  • Moderators

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.

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...