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. Don’t forget to sign up for the Hive Cup. There’s a 555 EUR prize pool. Sign up now!
    Dismiss Notice
  4. The Hive Workshop Cup contest results have been announced! See the maps that'll be featured in the Hive Workshop Cup tournament!
    Dismiss Notice
  5. Units have been turned into heroes in our latest Icon Contest! Vote for the best icon set at the Icon Contest #18 Poll!
    Dismiss Notice
  6. The poll for Hive's 12th Concept Art Contest is up! Go cast your vote for your favourite genie!
    Dismiss Notice
  7. The raddest synthwave tracks were chosen - Check out our Music Contest #12 - Results and congratulate the winners!
    Dismiss Notice
  8. 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.

Things That Leak

Discussion in 'Triggers & Scripts' started by Ralle, Jun 10, 2007.

  1. Vladadamm

    Vladadamm

    Joined:
    Apr 19, 2011
    Messages:
    1,255
    Resources:
    9
    Maps:
    5
    Spells:
    3
    Tutorials:
    1
    Resources:
    9
    But this isn't an answer to my question and doesn't solve my problem.
     
  2. kkots

    kkots

    Joined:
    Jun 21, 2007
    Messages:
    534
    Resources:
    0
    Resources:
    0
    Why does it leak if you don't modify anything, Vladadamm?
    ForGroupBJ (which is the Unit Group-Pick every unit in unit group loop in GUI) doesn't create any locals or set any variables.
     
    Last edited: Dec 19, 2011
  3. Vladadamm

    Vladadamm

    Joined:
    Apr 19, 2011
    Messages:
    1,255
    Resources:
    9
    Maps:
    5
    Spells:
    3
    Tutorials:
    1
    Resources:
    9
    Because Dynamics unit groups leaks ?

    And since it's a dynamic unit group, it leaks.
     
  4. kkots

    kkots

    Joined:
    Jun 21, 2007
    Messages:
    534
    Resources:
    0
    Resources:
    0
    Even if you 'add to group' or 'remove from group' a unit (using GroupAddUnit(group,unit) or GroupRemoveUnit(group,unit) native functions) there won't be any leaks. If you just cycle through the unit group in the way which you showed (post #955) there are still no leaks.
    You shouldn't worry about leaks, because there are none, even if something is done with that group.

    If you want to make it so that units cannot be added or removed from that group (which can only be done with triggers, or when the corpse of the unit has fully decayed after 88 seconds), then you should use an array of units instead of a group. You can fully control how units are added or removed, except that when a unit dies and decays for too long, then it is removed automatically and the group doesn't have that unit any more in it.
     
  5. Kadabra

    Kadabra

    Joined:
    Nov 16, 2011
    Messages:
    53
    Resources:
    0
    Resources:
    0
    As i said
     
  6. Troll-Brain

    Troll-Brain

    Joined:
    Apr 27, 2008
    Messages:
    2,372
    Resources:
    1
    JASS:
    1
    Resources:
    1
    No, they are not removed of the group automatically, but you can't enum them (short story), we call them ghost units : units removed of the game but not of the group.
    In the case you don't remove all units using GroupClear or GroupRemoveUnit, or just a GroupEnum... function, you still can clean the group periodically, like using the function GroupRefresh of the vJass library GroupUtils (just as an example)

    Theorically there will be a performance issue with a group full of many ghost units comparing to the same group without ghost units, but i don't think that will be ever noticeable in any real case, especially in GUI.
     
  7. kkots

    kkots

    Joined:
    Jun 21, 2007
    Messages:
    534
    Resources:
    0
    Resources:
    0
    Remove the unit from the group as soon as it dies? Will that fix the ghost units problem?
     
  8. Magtheridon96

    Magtheridon96

    Joined:
    Dec 12, 2008
    Messages:
    6,006
    Resources:
    26
    Maps:
    1
    Spells:
    8
    Tutorials:
    7
    JASS:
    10
    Resources:
    26
    ^ Actually, that will partly fix the problem since units could also get removed :/
    You can hook RemoveUnit, but seriously, I wouldn't recommend that, I mean ghost units don't cause major performance problems.
     
  9. Troll-Brain

    Troll-Brain

    Joined:
    Apr 27, 2008
    Messages:
    2,372
    Resources:
    1
    JASS:
    1
    Resources:
    1
    Or instead of simply remove unit, Kill it before. (easy GUI fix)
    Ofc in case an unit can resurect and you don't want to remove it, that wouldn't work.
    But seriously, as i've mentioned i don't think you really need to care about that, i just said it for the sake of accuracy.
     
  10. Bribe

    Bribe

    Joined:
    Sep 26, 2009
    Messages:
    8,030
    Resources:
    25
    Maps:
    3
    Spells:
    10
    Tutorials:
    3
    JASS:
    9
    Resources:
    25
    I think you'd have to be spawning at least a million units over time to notice an issue. Possibly millions, but I haven't got time to test that as my computer won't support more than 1000 created units at a time.

    Most lag will be caused by corpse decay and the blood splatter of exploded units. The corpse decay was such a problem for me in WarChasers 2 that I set the decay time to 12 seconds or something.

    In a lot of cases you can use dummy recycling or not even need to create extra dummies in the first place (like having one dummy caster for most tasks).
     
  11. Palooo3

    Palooo3

    Joined:
    Nov 24, 2010
    Messages:
    544
    Resources:
    2
    Maps:
    2
    Resources:
    2
    Hello guys, I am new to triggering and removing leaks, here is my question:

    • ManaTideTotem
      • Events
        • Time - Every 3.00 seconds of game time
      • Conditions
        • (Number of units in (Units of type Tidal Totem)) Equal to 1
      • Actions
        • Set HolHin_Mana = (Random real number between 2.00 and 5.00)
        • Unit Group - Pick every unit in (Units within 1000.00 of (Position of HolHin_Totem)) and do (Actions)
          • Loop - Actions
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • (Unit-type of (Picked unit)) Not equal to Lady Seraspia
                • (Unit-type of (Picked unit)) Not equal to Tidal Totem
              • Then - Actions
                • Unit - Set mana of (Picked unit) to ((Mana of (Picked unit)) + HolHin_Mana)
                • Floating Text - Create floating text that reads ((|c000000ff+ + (String((Integer(HolHin_Mana))))) + mana|r) above (Picked unit) with Z offset 0.00, using font size 8.50, color (100.00%, 100.00%, 100.00%), and 0.00% transparency
                • Floating Text - Change (Last created floating text): Disable permanence
                • Floating Text - Change the lifespan of (Last created floating text) to 1.25 seconds
                • Floating Text - Change the fading age of (Last created floating text) to 1.00 seconds
                • Floating Text - Set the velocity of (Last created floating text) to 85.00 towards 135.00 degrees
              • Else - Actions


    Does this leak in group?
     
  12. Vladadamm

    Vladadamm

    Joined:
    Apr 19, 2011
    Messages:
    1,255
    Resources:
    9
    Maps:
    5
    Spells:
    3
    Tutorials:
    1
    Resources:
    9
    This leak group and location, and mbe the condition leaks (i dunno for this one).
     
  13. Palooo3

    Palooo3

    Joined:
    Nov 24, 2010
    Messages:
    544
    Resources:
    2
    Maps:
    2
    Resources:
    2
    Spells work as I wanted it to do so, but I don't know how to really remove leaks, could you please tell me ?:D I got several simillar triggers so I guess all of them leaks, I would like to clear it.
     
  14. Bribe

    Bribe

    Joined:
    Sep 26, 2009
    Messages:
    8,030
    Resources:
    25
    Maps:
    3
    Spells:
    10
    Tutorials:
    3
    JASS:
    9
    Resources:
    25
    Yes the conditions leak to. The solution is to use an if/then/else (multiple conditions) and do everything in the actions, so that you can destroy the group.

    If there were no "conditions", then everyone would just use the if/then/else (multiple conditions) block. They are not really important.
     
  15. Vladadamm

    Vladadamm

    Joined:
    Apr 19, 2011
    Messages:
    1,255
    Resources:
    9
    Maps:
    5
    Spells:
    3
    Tutorials:
    1
    Resources:
    9
    Or you just should to turn on/off the trigger ^^

    It's the best optimisation way, no ?
     
  16. Bribe

    Bribe

    Joined:
    Sep 26, 2009
    Messages:
    8,030
    Resources:
    25
    Maps:
    3
    Spells:
    10
    Tutorials:
    3
    JASS:
    9
    Resources:
    25
    Well, yes ;)
     
  17. furryfox92

    furryfox92

    Joined:
    Feb 19, 2012
    Messages:
    19
    Resources:
    0
    Resources:
    0
    After i destroy the Group with the call DestroyGroup(udg_Group) the spell doesnt work again after it, but if i need to destroy the group to stop any leaks what am i supposed to do to keep it working?
     
  18. WaterKnight

    WaterKnight

    Joined:
    Aug 18, 2009
    Messages:
    4,033
    Resources:
    5
    Maps:
    1
    Tutorials:
    4
    Resources:
    5
    When you need the group over and over again, you reuse it and therefore it does not allocate new memory. It does not leak.
     
  19. DSanhueza

    DSanhueza

    Joined:
    Mar 31, 2012
    Messages:
    101
    Resources:
    4
    Maps:
    4
    Resources:
    4
    Can somebody please add to the first post what leaks are? I mean like a little description because I kinda know but I am not sure what it really means :c
     
  20. Magtheridon96

    Magtheridon96

    Joined:
    Dec 12, 2008
    Messages:
    6,006
    Resources:
    26
    Maps:
    1
    Spells:
    8
    Tutorials:
    7
    JASS:
    10
    Resources:
    26
    A memory leak is when you have memory that does nothing, so it takes up space for no reason.
    Warcraft III will become slower the more the number of leaks.

    Imagine 700MB of RAM doing nothing but taking up space.

    You can fix this by /destroying/ those leaks :D