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

[Trigger] Help with leaks pls

Status
Not open for further replies.
Level 10
Joined
Jan 19, 2010
Messages
393
Pls help me with leaks here thx
  • HashTable
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Hashtable - Create a hashtable
      • Set Hashtable = (Last created hashtable)
  • Heal start
    • Events
      • Unit - A unit Begins casting an ability
    • Conditions
      • (Ability being cast) Equal to Heal
    • Actions
      • Hashtable - Save Handle Of(Target unit of ability being cast) as (Key target) of (Key (Triggering unit)) in Hashtable
      • Unit Group - Add (Triggering unit) to Casters
      • Trigger - Turn on Heal Loop <gen>
  • Heal Loop
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Heal
    • Actions
      • Unit Group - Pick every unit in Casters and do (Actions)
        • Loop - Actions
          • Set LifeMana[1] = ((Max life of (Load (Key target) of (Key (Picked unit)) in Hashtable)) - (Life of (Load (Key target) of (Key (Picked unit)) in Hashtable)))
          • Set LifeMana[2] = (Mana of (Picked unit))
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • LifeMana[1] Greater than ((Real((Level of Heal for (Picked unit)))) x 100.00)
            • Then - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • LifeMana[2] Less than ((Real((Level of Heal for (Picked unit)))) x 100.00)
                • Then - Actions
                  • Unit - Set life of (Load (Key target) of (Key (Picked unit)) in Hashtable) to ((Life of (Load (Key target) of (Key (Picked unit)) in Hashtable)) + LifeMana[2])
                  • Unit - Set mana of (Picked unit) to (LifeMana[2] - LifeMana[2])
                  • Unit Group - Remove (Picked unit) from Casters
                • Else - Actions
                  • Set XXXXX = ((Real((Level of Heal for (Picked unit)))) x 100.00)
                  • Unit - Set life of (Load (Key target) of (Key (Picked unit)) in Hashtable) to ((Life of (Load (Key target) of (Key (Picked unit)) in Hashtable)) + XXXXX)
                  • Unit - Set mana of (Picked unit) to ((Mana of (Picked unit)) - XXXXX)
                  • Unit Group - Remove (Picked unit) from Casters
            • Else - Actions
              • Unit - Set life of (Load (Key target) of (Key (Picked unit)) in Hashtable) to ((Life of (Load (Key target) of (Key (Picked unit)) in Hashtable)) + LifeMana[1])
              • Unit - Set mana of (Picked unit) to ((Mana of (Picked unit)) - LifeMana[1])
              • Unit Group - Remove (Picked unit) from Casters
thx to all
 
Level 28
Joined
Jan 26, 2007
Messages
4,789
Hm, I would suggest adding this action when the spell if finished:
  • Hashtable - Clear all child hashtables of child (Key (Picked unit)) in Hashtable
It's said to leak if you do not remove it, but I honestly did not test this yet.
(It will clear all data related to the caster in the hashtable, thus it will also remove the stored data, cleaning the memory partially).
 
ap0calypse, nice catch. For the clear child hashtables action, it's not only used for leak issues, it's also used to actually make MUI happen for the same unit. If you store an integer for example on a unit and you don't clear the hash children of the main hash, that are related to the unit, that integer (if it's an increasing one) will return the value that it previously had +/- the new increasing value. So, if the value was 0 and the spell is supposed to end after it gets 20, the new value will be (20 + (the increasing integer)). You know that, but I also refer to the OP.
 
Level 28
Joined
Jan 26, 2007
Messages
4,789
ap0calypse, nice catch. For the clear child hashtables action, it's not only used for leak issues, it's also used to actually make MUI happen for the same unit. If you store an integer for example on a unit and you don't clear the hash children of the main hash, that are related to the unit, that integer (if it's an increasing one) will return the value that it previously had +/- the new increasing value. So, if the value was 0 and the spell is supposed to end after it gets 20, the new value will be (20 + (the increasing integer)). You know that, but I also refer to the OP.
Yeah, I was also thinking about that... but then I thought that the new values 'should' be overwritten in the cast-trigger (of course: this doesn't always happen for values that are 0 from the start for example).
Thanks for clearing this up, it saves me some time (I would've made a test-map for it if you did not tell me this ^^).
 
Status
Not open for further replies.
Top