• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!

Leak: do triggerconditions leak?

Status
Not open for further replies.
Level 7
Joined
Jan 30, 2011
Messages
267
when adding a boolexpr to a trigger it returns you a triggercondition
after doing TriggerRemoveCondition, will the triggercondition still exist?
if yes, can it be destroyed somehow? (DestroyCondition only takes conditionfunc)
 
Level 23
Joined
Apr 16, 2012
Messages
4,041
each triggercondition only leaks once because each function generates ONE triggercondition, so upon calling TriggerAddCondition you will leak but calling TriggerAddCondition second time will not leak and I dont think TriggerRemoveCondition does/nt leak

I dont know but I know that boolexprs based on the same functions are the same
 
Level 7
Joined
Jan 30, 2011
Messages
267
i did this test:
JASS:
struct trigcontest extends array
    static method a takes nothing returns boolean
        return true
    endmethod
    static method onInit takes nothing returns nothing
        local trigger trig = CreateTrigger()
        local boolexpr bool = Condition(function thistype.a)
        local triggercondition con1 = TriggerAddCondition(trig, bool)
        local triggercondition con2
        local triggercondition con3
        call TriggerRemoveCondition(trig, con1)
        set con2 = TriggerAddCondition(trig, bool)
        set con3 = TriggerAddCondition(trig, bool)
        if(con1 == con2) then
            call DisplayTextToPlayer(GetLocalPlayer(), 0, 0, "A")
        endif
        if(con3 == con2) then
            call DisplayTextToPlayer(GetLocalPlayer(), 0, 0, "B")
        endif
        call DisplayTextToPlayer(GetLocalPlayer(), 0, 0, I2S(GetHandleId(bool)))
        call DisplayTextToPlayer(GetLocalPlayer(), 0, 0, I2S(GetHandleId(con1)))
        call DisplayTextToPlayer(GetLocalPlayer(), 0, 0, I2S(GetHandleId(con2)))
        call DisplayTextToPlayer(GetLocalPlayer(), 0, 0, I2S(GetHandleId(con3)))
    endmethod
endstruct
neither A nor B has been displayed and they all have different handle ids
 
Level 7
Joined
Jan 30, 2011
Messages
267
now i did this test
JASS:
struct trigcontest2 extends array
    static trigger trig = CreateTrigger()
    static method a takes nothing returns boolean
        return true
    endmethod
    static boolexpr bool
    static method x takes nothing returns nothing
        
        local integer i = 0
        call DisplayTextToPlayer(GetLocalPlayer(), 0, 0, "start")
        loop
            exitwhen i == 1000
            call TriggerAddCondition(trig, bool)
            set i = i+1
        endloop
        call DisplayTextToPlayer(GetLocalPlayer(), 0, 0, "done")
    endmethod
    
    static method onInit takes nothing returns nothing
        call TimerStart(CreateTimer(), 1., true, function thistype.x)
        set bool = Condition(function thistype.a)
    endmethod
endstruct
each call of function x increased memory of war3.exe by about 400-500 KB
 
Status
Not open for further replies.
Top