• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Does KillUnit(GetTriggerUnit()) Leak?

Status
Not open for further replies.
JASS:
function KillTriggerUnit takes nothing returns nothing
    local unit U=GetTriggerUnit()
    call KillUnit(U)
    set U=null
endfunction
Do I have to set unit U to null at the end of the function? I'm pretty sure I do. Also, do I even have to have the local variable or will only using call KillUnit(GetTriggerUnit()) work as well without leaking?

This function is used in a trigger's condition if it matters.
 
For any handle that's destroyed you have to null all references (locals, globals) to it or else it will leak.

Also, killing the unit doesn't remove it so yeah it does leak.

EDIT: I ran some more tests and apparently when the unit decays it's removed, however there's still that leak you can't get rid of.

My previous tests were invalid because I was checking the handle id of a killed unit.

JASS:
//So basically
local unit u = CreateUnit(Player(0), 'hfoo', 0, 0, 0)
call BJDebugMsg(I2S(GetHandleId(u)))
call BJDebugMsg(I2S(GetUnitTypeId(u)))
call RemoveUnit(u)
call TriggerSleepAction(0)
call BJDebugMsg(I2S(GetUnitTypeId(u))) // displays 0
call BJDebugMsg(I2S(GetHandleId(u))) // should display same thing no matter how much time has passed
 
Last edited:
Level 19
Joined
Mar 18, 2012
Messages
1,716
To summarize it for you
a) declared local and global unit variables should be nulled once you are done with them.
b) call KillUnit(GetTriggerUnit()) does not leak per se and can be used savely.
c) however every removed (decayed or removed) unit leaves a very small leak behind, send complains to blizzard.

Aslong as you are not spamming tousands of units it shouldn't be a problem at all.
 
Status
Not open for further replies.
Top