• 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.

Leak?

Status
Not open for further replies.
Level 8
Joined
Mar 26, 2009
Messages
301
Do we have to nullify a unit variable after variable does its job? "Yes" you will say probably but what i am asking is: if variable is used in a repeatable trigger, what is the point of nullifying it each time? For ex: You cast a storm bolt, then trigger creates a dummy unit to cast corruption on stormbolt target. And that dummy is appointed to a variable (i know it's not necessary in this scenario but just assume that we have no other choice) So, storing same variable to different unit each time will use extra memory and cause leak? (Although unit type is same in object editor - which is Dummy- since we create a new one for each spellcast, it is technically a different unit)

And btw, which variables do leak and needs to be nullified after usage?
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,287
The memory allocated to the object like unit will always be recycled on death.

The handle index however will only be recycled once all references to it are removed. This does not occur automatically and so you have to eithor null all references or change them to reference another handle so it can recycle the index.

Globals generally can not leak handle indexes unless they are never reused.
Locals however (ones not created when passing arguments) can leak references to handles and prevent the index being recycled. This is due to the variable being destroyed but the reference it made not being unregistered. Thus you need to null local handles for anything which has a recyclable handle index.
 
Level 7
Joined
Oct 26, 2005
Messages
190
It has to be set later to No unit, since even when the unit is removed, the variable stores its value, and the multiple acummulation of these (casting that spell continously) will cause the leak. Remember we use variables on dummies with different variable names to make them work specifically on that trigger, since if 2 spells casted one after another will make only the 2nd spell work if you set them to Last created unit.

And most leaks occur on units, special effects/animations, points, unit groups, created regions (by triggers, no preset), floating texts... I guess thats all. For units, effects and floating texts can be removed by their (Destroy) Action. The other ones require a Custom Script, I remember a few:

Points: call RemoveLocation (udg_[Name of Point Variable Here])
Groups: call DestroyGroup (udg_[Name of U-Group Var[)

Hope I helped :)
 
Status
Not open for further replies.
Top