- Joined
- Oct 11, 2012
- Messages
- 711
Hi all. If triggers are registered dynamically, do the boolxpr variables added to them need to be destroyed to prevent memory leak? Please see the following example if you have time, thanks a lot.
JASS:
function con takes nothing returns nothing
.........
call DestroyTrigger(GetTriggeringTrigger())
endfunction
function run takes nothing returns nothing
local boolexpr expr = Condition(function con)
local trigger trig = CreateTrigger()
local unit target = GetSpellTargetUnit()
call TriggerRegisterUnitEvent(trig,target,EVENT_UNIT_DAMAGED)
call TriggerAddCondition(trig,expr)
set expr = null
set trig = null
set target = null
endfunction
function init takes nothing returns nothing
local trigger t = CreateTrigger()
call TriggerRegisterUnitEvent( t, gg_unit_Hpal_0000, EVENT_UNIT_SPELL_EFFECT )
call TriggerAddCondition(t, Condition(function run))
set t = null
endfunction