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

do unit handles auto-clear?

Status
Not open for further replies.
Level 4
Joined
Feb 22, 2012
Messages
74
It's weird because the leak tutorial says everything basically except values will leak, so I am wondering if things like "triggering unit" leaks and if so how do you destroy a unit variable (i.e "call DestroyUnit(udg_tempUnit)".

My guess is that unit handles remain in memory until that unit decays?

Also does it not leak because it is technically an integer?

Unit handles are just unique integers right?
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
Units, Reals and Integers doesn't leak.
Points, Special Effects, Unit Groups, Forces (Player Groups) leaks.

If you use (Triggering Unit) it doesn't leak.
If you store (Triggering Unit) into a variable, and that unit dies, the variable will hold the value of the death unit until you replace it, or null it, meanwhile it will store the info of the unit there (wich may be considered as a leak, since it's useless information)

I'm not sure if all the information saved onto a unit ID is cleared automatically when this unit dies and is removed from the game, but I doubt so. I think you have to create a trigger to clear all child data from Unit ID in the hashtable in order to clear the stored data when the unit dies.
 
It's weird because the leak tutorial says everything basically except values will leak, so I am wondering if things like "triggering unit" leaks and if so how do you destroy a unit variable (i.e "call DestroyUnit(udg_tempUnit)".

You only do things like "set unit = null" if "unit" is a local variable or if it's an array variable that you may never reference again. This is not something you typically concern yourself with in GUI since you'd need to use custom script to declare a local variable making the use of local variables in GUI pretty rare.

My guess is that unit handles remain in memory until that unit decays?

Since the unit IS the handle, yes.

Also does it not leak because it is technically an integer?

JASS handle variables are "smart pointers" meaning the handle index cannot be recycled until all smart pointers are no longer pointing to it. This is not something you typically concern yourself with in GUI since tons of things in GUI leak handle ID's.

Unit handles are just unique integers right?

No, the handle ID's are unique integers, but the ID points to an address in memory (RAM) and so your RAM will remain high until the handle is removed (in the case of a unit it will need RemoveUnit or some natural decay/explosion event).
 
Level 37
Joined
Mar 6, 2006
Messages
9,243
If you store (Triggering Unit) into a variable, and that unit dies, the variable will hold the value of the death unit until you replace it, or null it, meanwhile it will store the info of the unit there (wich may be considered as a leak, since it's useless information)

Variables hold information of where the "real" data is stored.

local unit u = GetTriggerUnit()

There is an object for triggering unit somewhere in the memory. The u variable no points to the object, but does not hold the actual data of triggering unit object. It tells the address where we can find the data.
 
Status
Not open for further replies.
Top