• 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.
  • It's time for the first HD Modeling Contest of 2025. Join the theme discussion for Hive's HD Modeling Contest #7! Click here to post your idea!

Hashtable Leak?

Status
Not open for further replies.
Level 9
Joined
Jul 3, 2008
Messages
495
JASS:
local unit u = CreateUnit(Player(0),'hfoo',0,0,0)
call SaveUnitHandle(udg_hashtable,1,1,u)
set u = null

In this code, we created a local variable to store the unit into the hashtable.
And after that we had to null the local variable.

What about this script below. Now we did not created any local variables.
But will this leak in some way?
JASS:
call SaveUnitHandle(udg_hashtable,1,1,CreateUnit(Player(0),'hfoo',0,0,0))
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,264
Yes, it is faster. However remember to clear it from the hash table when no longer needed or the index will not get recycled and the hashtable will have an index blocked permantly. (hashtables use arrays of fixed size which results in them slowing down when full I believe).

Luckilly there are like 3 natives you can use to remove handles from hashtables, those are flush a specific location, flush a parent and flush the whole damn thing. Highly convenient hehe. . .
 
Status
Not open for further replies.
Top