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 Lich King demands your service! We've reached the 19th edition of the Icon Contest. Come along and make some chilling servants for the one true king.
    Dismiss Notice
  4. The 4th SFX Contest has started. Be sure to participate and have a fun factor in it.
    Dismiss Notice
  5. The poll for the 21st Terraining Contest is LIVE. Be sure to check out the entries and vote for one.
    Dismiss Notice
  6. The results are out! Check them out.
    Dismiss Notice
  7. Don’t forget to sign up for the Hive Cup. There’s a 555 EUR prize pool. Sign up now!
    Dismiss Notice
  8. The Hive Workshop Cup contest results have been announced! See the maps that'll be featured in the Hive Workshop Cup tournament!
    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.

Things That Leak

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

  1. HammerFist132

    HammerFist132

    Joined:
    Mar 22, 2012
    Messages:
    1,314
    Resources:
    17
    Models:
    11
    Icons:
    2
    Maps:
    2
    Spells:
    2
    Resources:
    17
    This is eng forum, stop with that language, spanish or whatever to it is. How would u fill if someone try to explain u leak like this:

    Brate znas kako to ti uklanja nepotrebne stvari da bi ti se ram ne bi opteretion. Bar mislim da je to lik.

    So thisa is not epicwar, here u cannpot post something what is not on eng.
     
  2. KnnO

    KnnO

    Joined:
    Sep 18, 2011
    Messages:
    156
    Resources:
    3
    Icons:
    1
    Maps:
    1
    Spells:
    1
    Resources:
    3
    Rect and Regions

    Code (vJASS):

        local rect rect_1 = Rect(x-400.,y-400.,x+400.,y+400.)
        local rect rect_2 = RectFromCenterSizeBJ(loc, 400.0, 400.0)
        local region region_1 = CreateRegion()
        RegionAddRect(region_1 , rect_1)
        RegionAddRect(region_1 , rect_2)
        //...1
        RemoveRect(rect_1)
        RemoveRect(rect_2)
        //...2
     

    1. After I added the rects, Does the region need the rects not-destroyed to work?
    2. Rect and Regions both leaks?
     
  3. Magtheridon96

    Magtheridon96

    Joined:
    Dec 12, 2008
    Messages:
    6,006
    Resources:
    26
    Maps:
    1
    Spells:
    8
    Tutorials:
    7
    JASS:
    10
    Resources:
    26
    If the region is being used for a Unit-Enter-Region Event, then don't destroy it.
    The game doesn't create a copy of this region for the event, it uses the same region you passed in, so destroying the region will render your trigger useless.

    As for rects, I'm not very sure, but I believe destroying them should cause the same side-effects.
     
  4. Troll-Brain

    Troll-Brain

    Joined:
    Apr 27, 2008
    Messages:
    2,372
    Resources:
    1
    JASS:
    1
    Resources:
    1
    Since rects are added to regions "by value" and not "by reference", if you don't need them anymore, then you can destroy them.

    Rects and regions leak if you don't destroy them when you don't have the need anymore, but that's pretty much like every handles (excepted texttags probably since there is an hardcoded limit of 100 texttags)
    There is also the special case with boolexpr created with Filter() and Condition(), never destroy them if you don't know exactly what you're doing.
     
  5. Chewii

    Chewii

    Joined:
    Dec 5, 2009
    Messages:
    841
    Resources:
    0
    Resources:
    0
    I have a question, if a unit dies will it leak? or do i have to remove the unit when it dies?
     
  6. CoLd Bon3

    CoLd Bon3

    Joined:
    Aug 8, 2010
    Messages:
    948
    Resources:
    4
    Spells:
    4
    Resources:
    4
    Unit, doodads, destructibles and more don't leak. However, if you move a unit to a point and then do something with the unit, the point will leak.
     
  7. Dr Super Good

    Dr Super Good

    Spell Reviewer

    Joined:
    Jan 18, 2005
    Messages:
    25,596
    Resources:
    3
    Maps:
    1
    Spells:
    2
    Resources:
    3
    Units do leak. There is some internal game bug that removing a unit (any means including natural death) does not removal all memory used by a unit. There is no way to avoid this leak next to unit recycling (re-use existing units instead of making more).
     
  8. CoLd Bon3

    CoLd Bon3

    Joined:
    Aug 8, 2010
    Messages:
    948
    Resources:
    4
    Spells:
    4
    Resources:
    4
    I will go kill myself. Gimme gun! :goblin_jawdrop:
     
  9. Troll-Brain

    Troll-Brain

    Joined:
    Apr 27, 2008
    Messages:
    2,372
    Resources:
    1
    JASS:
    1
    Resources:
    1
    IIRC this leak is very minor or there is even no leak at all.
    For some simple and precise applications like dummies units, recycling is fine, as it is far more efficient.
    For the rest, recycling brings more problems than just create/destroy units.

    But for destructable it's significant, can't say how many bytes but that's clearly visible (i tested it with some tree, it could be not the same with other destructable).

    For doodads they can't be removed anyway, right ?
     
  10. PurgeandFire

    PurgeandFire

    Code Moderator

    Joined:
    Nov 11, 2006
    Messages:
    7,426
    Resources:
    18
    Icons:
    1
    Spells:
    4
    Tutorials:
    9
    JASS:
    4
    Resources:
    18
    The unit leak used to be a major problem in patch 1.24, but I think they fixed it when they released 1.25. Maybe they did not fix it completely (I don't remember), but people actually ran into memory limits after playing about fifteen minutes to half an hour into a melee map. That doesn't seem to happen anymore, and I remember running tests a long time ago to test if the memory problem was still as great and found that they weren't.
     
  11. Troll-Brain

    Troll-Brain

    Joined:
    Apr 27, 2008
    Messages:
    2,372
    Resources:
    1
    JASS:
    1
    Resources:
    1
    Meh, hopefully we have complete and precise changelogs with an update.
    So we can't have jass myths and legends.

    Oh wait ... we have not :/
     
  12. blit_40912

    blit_40912

    Joined:
    Sep 22, 2012
    Messages:
    86
    Resources:
    0
    Resources:
    0
    noob here, someone please help. how do i know references from triggers? i've started making some triggers with clearing mem leaks like location with polar offsets and unit groups. here is my map: http://www.hiveworkshop.com/forums/spells-569/8-way-arrowkeys-223047/


    please help. I want to learn gui triggers T_T
     
  13. king_nelu

    king_nelu

    Joined:
    Jul 17, 2007
    Messages:
    6
    Resources:
    0
    Resources:
    0
    I LOVE you so much for this :D
     
  14. Lohengrin

    Lohengrin

    Joined:
    Jan 27, 2008
    Messages:
    60
    Resources:
    0
    Resources:
    0
    Hm, the set bj want destroy group custom script removed the special effect from the group of units.
     
  15. Ralle

    Ralle

    Owner

    Joined:
    Oct 6, 2004
    Messages:
    11,235
    Resources:
    22
    Tools:
    3
    Maps:
    5
    Tutorials:
    14
    Resources:
    22
    Are you assigning the group to a variable and using it later? Then it might be gone already. Can I see your code?
     
  16. Lohengrin

    Lohengrin

    Joined:
    Jan 27, 2008
    Messages:
    60
    Resources:
    0
    Resources:
    0
    • Indignation Visual
      • Events
        • Unit - A unit Starts the effect of an ability
      • Conditions
        • (Ability being cast) Equal to Indignation (Neutral Hostile 1)
      • Actions
        • Set IndignationGroup = (Units within 375.00 of (Position of (Triggering unit)))
        • For each (Integer A) from 1 to 5, do (Actions)
          • Loop - Actions
            • Custom script: set bj_wantDestroyGroup = true
            • Unit Group - Pick every unit in (Random 1 units from IndignationGroup) and do (Special Effect - Create a special effect attached to the overhead of (Random unit from IndignationGroup) using Abilities\Spells\Other\Monsoon\MonsoonBoltTarget.mdl)
            • Special Effect - Destroy (Last created special effect)
        • Custom script: call DestroyGroup (udg_IndignationGroup)


    It might be because of the loop? Or I placed it in the wrong place.

    Oh wait, I just realized that it might be redundant, lol.
     
  17. Ralle

    Ralle

    Owner

    Joined:
    Oct 6, 2004
    Messages:
    11,235
    Resources:
    22
    Tools:
    3
    Maps:
    5
    Tutorials:
    14
    Resources:
    22
    You are picking a random unit from the group 5 times and creating a special effect which you immediately destroy. This does not work.
    You need to insert waits, but when doing that, it will not be MUI, so you need local variables, which are not accessible through GUI.
    The way you would do it would be to have an array containing each special effect after you create them, then after x seconds, you destroy the special effects.
     
  18. Lohengrin

    Lohengrin

    Joined:
    Jan 27, 2008
    Messages:
    60
    Resources:
    0
    Resources:
    0
    The special effect works just fine without the first custom script in the trigger.

    I just thought that the trigger leaked without it, but it doesn't, correct?
     
  19. Vladadamm

    Vladadamm

    Joined:
    Apr 19, 2011
    Messages:
    1,255
    Resources:
    9
    Maps:
    5
    Spells:
    3
    Tutorials:
    1
    Resources:
    9
    • Indignation Visual
      • Events
        • Unit - A unit Starts the effect of an ability
      • Conditions
        • (Ability being cast) Equal to Indignation (Neutral Hostile 1)
      • Actions
        • Set TempLoc = (Position of (Triggering unit))
        • Set IndignationGroup = (Units within 375.00 of TempLoc)
        • For each (Integer A) from 1 to 5, do (Actions)
          • Loop - Actions
            • Special Effect - Create a special effect attached to the overhead of (Random unit from IndignationGroup) using Abilities\Spells\Other\Monsoon\MonsoonBoltTarget.mdl)
            • Special Effect - Destroy (Last created special effect)
        • Custom script: call DestroyGroup(udg_IndignationGroup)
        • Custom script: call RemoveLocation(udg_TempLoc)

    No need of group.

    If you want that an effect can't be created twice on the same unit :

    • Indignation Visual
      • Events
        • Unit - A unit Starts the effect of an ability
      • Conditions
        • (Ability being cast) Equal to Indignation (Neutral Hostile 1)
      • Actions
        • Set TempLoc = (Position of (Triggering unit))
        • Set IndignationGroup = (Units within 375.00 of TempLoc)
        • For each (Integer A) from 1 to 5, do (Actions)
          • Loop - Actions
            • Set TempUnit = (Random unit from IndignationGroup)
            • Special Effect - Create a special effect attached to the overhead of TempUnit using Abilities\Spells\Other\Monsoon\MonsoonBoltTarget.mdl)
            • Special Effect - Destroy (Last created special effect)
            • Unit Group - Remove TempUnit from IndignationGroup
        • Custom script: call DestroyGroup(udg_IndignationGroup)
        • Custom script: call RemoveLocation(udg_TempLoc)
     
  20. kevinruaza

    kevinruaza

    Joined:
    Sep 26, 2012
    Messages:
    5
    Resources:
    0
    Resources:
    0
    can i ask a Q. if you dont mind i want to know if the creation of a unit and i forgot to trigger it with an action "Remove (Bla bla) from game" will the unit cause a leak?