• 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.
  • The Hive's 22nd Icon Contest: Creep Abilities is now concluded, time to vote for your favourite set of icons! Click here to vote!
  • ✅ The POLL for Hive's Texturing Contest #34 is OPEN! Vote for the TOP 3 SKINS! 🔗Click here to cast your vote!
  • ✅ The POLL for Hive's Techtree Contest #20 is OPEN! Vote for the TOP 3 FACTIONS! 🔗Click here to cast your vote!

[General] (hashtable question, gui) Will setting a new value in a hashtable cause a leak

Status
Not open for further replies.
Level 3
Joined
May 5, 2007
Messages
21
Hello, was wondering when I need to clear an hashtable?

for example:

lets assume (Key cd) of (Key (Picked unit)) in AI_hashtable in the trigger under is set to 0.

  • Set temp_real = ((Load (Key cd) of (Key (Picked unit)) from AI_hashtable) + 0.10)
  • Hashtable - Clear all child hashtables of child (Key (Picked unit)) in AI_hashtable
  • Hashtable - Save temp_real as (Key cd) of (Key (Picked unit)) in AI_hashtable
would the "Hashtable - Clear all child hashtables of child (Key (Picked unit)) in AI_hashtable" be needed? or would simply skipping that part work just fine?

edit: shit, this should probably been in the Triggers & Scripts area, sorry
 
You flush child hashtables when the data stored will either no longer be needed or will become inaccessible (in a sense) and won't be overwritten. If you do not do so this data will accumulate in the hashtable slowly consuming more memory like a series of memory leaks. In this case whenever you need to stop tracking cd on that particular picked unit you should flush its children. This is usually when such a unit dies (but can't be revived) or is about to be removed from the map, or a (if this is a spell) when the spell ends its effect(s).
 
You flush child hashtables when the data stored will either no longer be needed or will become inaccessible (in a sense) and won't be overwritten. If you do not do so this data will accumulate in the hashtable slowly consuming more memory like a series of memory leaks. In this case whenever you need to stop tracking cd on that particular picked unit you should flush its children. This is usually when such a unit dies (but can't be revived) or is about to be removed from the map, or a (if this is a spell) when the spell ends its effect(s).

hmm.. so if this is for my "ai" during a duel, i shouldn't need to clear the hashtable until after the duel end?

Also does that mean I should clear "parent" and not just "child" for stuff like spells when the effects ends and none is currently casting the spell effect?
 
What you’re saying about the duel sounds correct.

As for clearing it depends on your methodology. To be clear: you can either flush all children of a particular parent or you can flush all children of all parents. If you’re using a different hashtable for each ‘thing’ you need one for then you can just clear the whole table. But if you are doing multiple things (say, spells) per hashtable then you would likely only want to clear specific data otherwise you might delete something else that another trigger/function is using.
 
Status
Not open for further replies.
Back
Top