• 🏆 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!

Clear Hashtable Leak

Status
Not open for further replies.
Level 10
Joined
Oct 31, 2009
Messages
352
Just make the Position of Picked Unit a variable and null it afterwards and the leak is gone :)

I tried this, but for some reason when I try to set a hashtable position to that variable and then clear the variable afterwards it won't work properly. Yet when I just do it to the hashtable directly, it works fine :*(

If it helps at all here are the triggers (all the spell does is send every hero on the map back 4 seconds in time to wherever they were standing 4 seconds previously):

  • Watchmaster Tick
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • Player Group - Pick every player in (All players matching (((Matching player) slot status) Equal to Is playing)) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • And - All (Conditions) are true
                • Conditions
                  • (Picked player) Not equal to Player 1 (Red)
                  • (Picked player) Not equal to Player 7 (Green)
            • Then - Actions
              • Hashtable - Save Handle Of(Load 3 of (Player number of (Picked player)) in Watchmaster_Hashtable) as 4 of (Player number of (Picked player)) in Watchmaster_Hashtable
              • Hashtable - Save Handle Of(Load 2 of (Player number of (Picked player)) in Watchmaster_Hashtable) as 3 of (Player number of (Picked player)) in Watchmaster_Hashtable
              • Hashtable - Save Handle Of(Load 1 of (Player number of (Picked player)) in Watchmaster_Hashtable) as 2 of (Player number of (Picked player)) in Watchmaster_Hashtable
            • Else - Actions
      • Unit Group - Pick every unit in Watchmaster_Tick and do (Actions)
        • Loop - Actions
          • Set Watchmaster_Handle = (Position of (Picked unit))
          • Hashtable - Save Handle Of(Position of (Picked unit)) as 1 of (Player number of (Owner of (Picked unit))) in Watchmaster_Hashtable
  • Watchmaster Cast
    • Events
      • Unit - A unit Finishes casting an ability
    • Conditions
      • (Ability being cast) Equal to Watchmaster
    • Actions
      • Unit Group - Pick every unit in Watchmaster_Tick and do (Actions)
        • Loop - Actions
          • Set Watchmaster_TempPos = (Position of (Picked unit))
          • Special Effect - Create a special effect at Watchmaster_TempPos using Abilities\Spells\Undead\DeathPact\DeathPactTarget.mdl
          • Special Effect - Destroy (Last created special effect)
          • Custom script: call RemoveLocation(udg_Watchmaster_TempPos)
          • Unit - Move (Picked unit) instantly to (Load 4 of (Player number of (Owner of (Picked unit))) in Watchmaster_Hashtable)
          • Special Effect - Create a special effect at Watchmaster_Save[((Player number of (Owner of (Picked unit))) x 4)] using Abilities\Spells\Undead\DeathPact\DeathPactTarget.mdl
          • Special Effect - Destroy (Last created special effect)
Please Note: The Watchmaster Tick Unit Group just contains all the heroes on the map
 
Just use this:
  • Actions
    • Set p = (Position of (Picked unit))
    • Hashtable - Save (X of p) as (Key x) of (Key (Owner of (Picked unit))) in Watchmaster_Hashtable
    • Hashtable - Save (Y of p) as (Key y) of (Key (Owner of (Picked unit))) in Watchmaster_Hashtable
    • Custom script: call RemoveLocation (udg_p)
You don't need to save it to the "number of the player". Saving it to the player himself is just fine.
The loading part:
  • Set X = (Load (Key(x)) of (Key(Owner of (Picked unit))) from Watchmaster_Hashtable
  • Set Y = (Load (Key(y)) of (Key(Owner of (Picked unit))) from Watchmaster_Hashtable
  • Set p2 = (Point(X,Y))
  • Unit - Move (Picked unit) instantly to p2
  • Custom script: call RemoveLocation (udg_p2)
 
Level 19
Joined
Feb 4, 2009
Messages
1,313
don't you have to clear the leak IN the hashtable? (like clear child of <someInteger>)
usually reals don't leak but since there is an infinite ammount of free slots in a hashtable it might make sense to clear every reference

I'll just check it wait a few minutes

edit: yeah you even have to clear every value in a hashtable with either
  • Hashtable - Clear (Last created hashtable)
or
  • Hashtable - Clear all child hashtables of child 0 in (Last created hashtable)
I'm not sure if it works perfectly though
it appears like it only deletes the last few million values but I'm not 100% certain about it and it shouldn't matter for any spellmaker anyway
 
Status
Not open for further replies.
Top