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

[Solved] Does a Variable Leak?

Status
Not open for further replies.
Thanks for stopping by, among the leak tutorials I've read I never gained a firm understanding of whether: 1. Recycled MUI variables leak, 2. If even a normal variable leaks.

Main Example: (Would a trigger like this leak, if so what would fix it?)

  • Start
    • Events
      • Something Happens
    • Conditions
    • Actions
      • Set Total_Indexes = (Total_Indexes + 1)
      • Set PointA[Total_Indexes] = (Point(200.00, 200.00))
      • Set PointB[Total_Indexes] = (Center of (Playable map area))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Total_Indexes Equal to 1
        • Then - Actions
          • Trigger - Turn on Loop <gen>
        • Else - Actions
The Loop Function:
  • Loop
    • Events
      • Time - Every 5.00 seconds of game time
    • Conditions
    • Actions
      • For each (Integer Loop_Count) from 1 to Total_Indexes, do (Actions)
        • Loop - Actions
          • Set Angle2Measure[Loop_Count] = (Angle from PointA[Loop_Count] to PointB[Loop_Count])
          • Special Effect - Create a special effect at PointA[Loop_Count] using Abilities\Spells\Human\ThunderClap\ThunderClapCaster.mdl
          • Special Effect - Destroy (Last created special effect)
          • -------- Clean up --------
          • Set PointA[Loop_Count] = PointA[Total_Indexes]
          • Set PointB[Loop_Count] = PointB[Total_Indexes]
          • Set Angle2Measure[Loop_Count] = Angle2Measure[Total_Indexes]
          • Set Total_Indexes = (Total_Indexes - 1)
          • Set Loop_Count = (Loop_Count - 1)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Total_Indexes Equal to 0
        • Then - Actions
          • Trigger - Turn off (This trigger)
        • Else - Actions
 
Level 39
Joined
Feb 27, 2007
Messages
5,010
The variable does not leak. The point object you allocate and never remove is what 'leaks' (because it eats memory and can never be removed once you overwrite the reference to it). You need to RemoveLocation on the 2 points before you assign them = the last index's points.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,198
Variables cannot leak by their very definition of being compile time declared global or local variables. What can leak is objects the variables refer to. In the case of JASS2 there is the nasty local declared local agent variable reference counter leak on return bug. LUA has no such bug.
 
Status
Not open for further replies.
Top