1. Updated Resource Submission Rules: All model & skin resource submissions must now include an in-game screenshot. This is to help speed up the moderation process and to show how the model and/or texture looks like from the in-game camera.
    Dismiss Notice
  2. DID YOU KNOW - That you can unlock new rank icons by posting on the forums or winning contests? Click here to customize your rank or read our User Rank Policy to see a list of ranks that you can unlock. Have you won a contest and still havn't received your rank award? Then please contact the administration.
    Dismiss Notice
  3. The poll for Hive's 12th Concept Art Contest is up! Go cast your vote for your favourite genie!
    Dismiss Notice
  4. Travel to distant realms and encounter scenes unknown to the common folk. The Greatest of Adventures is upon us with the 8th Cinematic Contest. Join in on a fun ride.
    Dismiss Notice
  5. The 18th Icon Contest is ON! Choose any ingame unit and give him/her Hero abilities. Good luck to all.
    Dismiss Notice
  6. Contestants are to create a scene set in the Stone Age. Come and see what you can come up with. We wish you the best of luck!
    Dismiss Notice
  7. Colour outside the lines! Techtree Contest #13 is a go. The contest is optionally paired.
    Dismiss Notice
  8. Greetings cerebrates, our Swarm needs new spawners that will have numerous children. Join the HIVE's 31st Modeling Contest - Spawners and Spawned! The contest is optionally paired.
    Dismiss Notice
  9. Check out the Staff job openings thread.
    Dismiss Notice
Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.

[Solved] Does a Variable Leak?

Discussion in 'Triggers & Scripts' started by Veronnis, Aug 5, 2019.

  1. Veronnis

    Veronnis

    Joined:
    Jul 19, 2010
    Messages:
    134
    Resources:
    6
    Models:
    2
    Icons:
    1
    Maps:
    3
    Resources:
    6
    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
     
  2. Pyrogasm

    Pyrogasm

    Joined:
    Feb 27, 2007
    Messages:
    2,793
    Resources:
    1
    Spells:
    1
    Resources:
    1
    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.
     
  3. Veronnis

    Veronnis

    Joined:
    Jul 19, 2010
    Messages:
    134
    Resources:
    6
    Models:
    2
    Icons:
    1
    Maps:
    3
    Resources:
    6
    @Pyrogasm I think I understand. Thanks again for your consistent help. If you have any interest in a reward pm me a restaurant, time zone, order and pickup name and you can have lunch / dinner on me :)
     
  4. Dr Super Good

    Dr Super Good

    Spell Reviewer

    Joined:
    Jan 18, 2005
    Messages:
    25,475
    Resources:
    3
    Maps:
    1
    Spells:
    2
    Resources:
    3
    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.
     
  5. Veronnis

    Veronnis

    Joined:
    Jul 19, 2010
    Messages:
    134
    Resources:
    6
    Models:
    2
    Icons:
    1
    Maps:
    3
    Resources:
    6
    Thanks Doc! :)