[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 45
Joined
Feb 27, 2007
Messages
5,578
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.
 
Status
Not open for further replies.
Top