HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Just Some Questions On Leaks

09-15-2006, 12:35 PM#1
PandaMine
I just have a few questions on leaks. The first one is if you use a native or a function that returns a handle and you dont save it in a variable but you use it in another function (i.e. GetLocationX/Y) does it still leak. Like in the following example

Collapse JASS:
set x = GetLocationX(GetSpellTargetLoc())
set y = GetLocationY(GetSpellTargetLoc())

will this leak and if it does it means you have to save the location as a variable like this

Collapse JASS:
set location point = GetSpellTargetLoc()
set x = GetLocationX(point)
set y = GetLocationY(point)
call RemoveLocation(point)

Also with cleaning up leaks when dealing with triggers, I heard that you need to use TriggerRemoveAction before destroying the Trigger by adding a wait in, is this true. i.e. if you have some function that is called by an action from a trigger

Collapse JASS:
function blah takes nothing returns nothing
local trigger temp = GetTriggeringTrigger()
//Some random script here
call TriggerRemoveAction(temp,blah)
call DestroyTrigger(temp)

is this enough to destroy the leak. BTW I wrote this on the run so the syntax may not be fully correct
09-15-2006, 12:38 PM#2
vile
Quote:
Collapse JASS:
set x = GetLocationX(GetSpellTargetLoc())
set y = GetLocationY(GetSpellTargetLoc())

will this leak and if it does it means you have to save the location as a variable like this

Yes, that will leak, you have to set the location in a variable, set the x/y and then remove the location using RemoveLocation.

Quote:
Also with cleaning up leaks when dealing with triggers, I heard that you need to use TriggerRemoveAction before destroying the Trigger by adding a wait in, is this true. i.e. if you have some function that is called by an action from a trigger

There is a thread about the gamecache bug, which wasn't a gamecache bug, but rather a destroy trigger bug. With tests, we figured out that after using a wait time of at least 30 seconds, and then destroying a specified trigger, removes any weird bugs occuring with it and other handles.

This is still in question because in my map, I dont get those problems, but then again, I use globals. So it seems this problem lies when using local triggers, and not global ones.