• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!

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,202
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