Sign in to follow this  
Followers 0
Carlo84

Releasing an Object.

4 posts in this topic

From: http://www.autoitscript.com/autoit3/docs/intro/ComRef.htm

When you assign an Object variable a different value, the 'pointer' will automatically be released. You can, for instance, force deletion of an Object by assigning it any number or any text value.

$oHTTP = ObjCreate("winhttp.winhttprequest.5.1")  ; Object is created
$oHTTP = 0                                        ; Object is deleted
But when i use ObjCreate in my script (in this case "ImageMagickObject.MagickImage.1") the memory usage of my script goes up (1k) but it wont go down after releasing the object.

is there anyway to get completely rid of this?

PS: creating the object again after "releasing" it does not cause memory usage to go up again

Share this post


Link to post
Share on other sites



There is a DLL call to release working memory from the process, but it isn't worth worrying about.

:unsure:


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

There are running multiple instances of my exe doing diffrent things, the diffrence of memory per instance all toghetter makes it worth it as it makes up for a huge diffrence, especially since they are idle most of the time, and run allong a program that requires a high amount of CPU and memory recourses.

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Thanks for the pointer, i think something in here will proof usefull :-)

[Edit:] The solution i used:

Func _ObjRelease(ByRef $Object)
    $Object = 0
    Local $ai_Handle = DllCall("kernel32.dll", 'int', 'OpenProcess', 'int', 0x1f0fff, 'int', False, 'int', @AutoItPID)
    Local $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', $ai_Handle[0])
    DllCall('kernel32.dll', 'int', 'CloseHandle', 'int', $ai_Handle[0])
    Return $ai_Return[0]
EndFunc   ;==>_ObjRelease

thanks to this post

Edited by Djarlo

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