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

[JASS] Hashtable: does "LoadUnitHandle" leak?

Status
Not open for further replies.
Level 12
Joined
Feb 22, 2010
Messages
1,115
"A function leaks" means "that function creates a NEW object".

I don't think none of the LoadHandle natives creates a new object(ever seen a LoadUnitHandle create a duplication of your unit?no?)

maybe LoadLocationHandle, you can't trust that evil locations man.

edit: Hope someone won't find out something like "LoadUnitHandle creates a unit object in memory which causes a permanent leak" in the future.
 
It does not leak. It simply returns the object that was saved in the hashtable in the first place.

LoadLocationHandle is fine as well. Even if you use LoadXHandle every 0.001 seconds, the memory usage won't go up.

Of course, you still have to remove the object (and flush the hashtable or remove that object from the hashtable). But the loading functions themselves do not create a new object/leak.
 
Level 11
Joined
Oct 11, 2012
Messages
711
"A function leaks" means "that function creates a NEW object".

I don't think none of the LoadHandle natives creates a new object(ever seen a LoadUnitHandle create a duplication of your unit?no?)

maybe LoadLocationHandle, you can't trust that evil locations man.

edit: Hope someone won't find out something like "LoadUnitHandle creates a unit object in memory which causes a permanent leak" in the future.
Thanks, Ceday.
It does not leak. It simply returns the object that was saved in the hashtable in the first place.

LoadLocationHandle is fine as well. Even if you use LoadXHandle every 0.001 seconds, the memory usage won't go up.

Of course, you still have to remove the object (and flush the hashtable or remove that object from the hashtable). But the loading functions themselves do not create a new object/leak.
Thanks, PnF. A further question, what if I still need to store things under the same parent and child key? In that case, I do not need to flush it right?
 
Level 12
Joined
Feb 22, 2010
Messages
1,115
Yes you don't need to flush between two save calls, just like you don't need GroupClear between two GroupEnum calls.

JASS:
// fine
SaveUnitHandle(hash, 0, 0, unit)
SaveTimerHandle(hash, 0, 0, timer)
 
Status
Not open for further replies.
Top