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. Magtheridon96

    Magtheridon96

    Joined:
    Dec 12, 2008
    Messages:
    6,003
    Resources:
    26
    Maps:
    1
    Spells:
    8
    Tutorials:
    7
    JASS:
    10
    Resources:
    26
    This is addressed at people who use the GUI, so a cJASS library isn't fit for them :/
     
  2. Daffa

    Daffa

    Joined:
    Jan 30, 2013
    Messages:
    8,201
    Resources:
    31
    Packs:
    1
    Maps:
    9
    Spells:
    18
    Tutorials:
    3
    Resources:
    31
    Mag also has a good point.
     
  3. LordDz

    LordDz

    Joined:
    May 11, 2007
    Messages:
    4,303
    Resources:
    0
    Resources:
    0
    Today I made the mistake of calling Custom script: call DestroyGroup(udg_tempPoint1), was a bit tired and didn't think correctly..
    And then hit save.
    ..
    I will never make that mistake again.
     
  4. jonhysone

    jonhysone

    Joined:
    Oct 29, 2012
    Messages:
    1,241
    Resources:
    1
    Maps:
    1
    Resources:
    1
    Why is the font of credits so small ? ._. Btw Good information
     
  5. deathismyfriend

    deathismyfriend

    Joined:
    Oct 24, 2012
    Messages:
    6,526
    Resources:
    14
    Spells:
    12
    Tutorials:
    2
    Resources:
    14
    this should be added to a unit group leak as not a lot of ppl think this leaks because it is use as an integer comparison condition.
    • (Number of units in (Units in (Playable map area))) Equal to 0
     
  6. Bribe

    Bribe

    Joined:
    Sep 26, 2009
    Messages:
    8,380
    Resources:
    25
    Maps:
    3
    Spells:
    10
    Tutorials:
    3
    JASS:
    9
    Resources:
    25
  7. deathismyfriend

    deathismyfriend

    Joined:
    Oct 24, 2012
    Messages:
    6,526
    Resources:
    14
    Spells:
    12
    Tutorials:
    2
    Resources:
    14
  8. plumsy460

    plumsy460

    Joined:
    Oct 2, 2013
    Messages:
    273
    Resources:
    0
    Resources:
    0
    Re-using or changing a var doesn't leak right?

    For instance:
    I set a var to a point -> spawn a unit at that point throught the var -> change the var to a new location/point -> spawn another unit at that new location through the var.

    As long as I reuse the var it's not considered leaking, yes?
     
  9. Tirlititi

    Tirlititi

    Joined:
    Jul 11, 2010
    Messages:
    396
    Resources:
    12
    Models:
    6
    Maps:
    2
    Spells:
    3
    JASS:
    1
    Resources:
    12
    Yes it is.
    Variables are not leaking, objects (like locations) are.
    If you change the variable to a new location, then you're creating a new location without clearing the old one : it leaks.

    There is an action for moving locations (and do what you want) but it's not available in the normal editor, only is UMSWE and such (some people say it bugs but I never experienced bugs from it myself). Unless you do that, you should remove the leak for each new object you create.
     
  10. Garfield1337

    Garfield1337

    Joined:
    Jul 6, 2009
    Messages:
    1,806
    Resources:
    4
    Maps:
    1
    Spells:
    3
    Resources:
    4
    It leaks. It's not about the variable, it's about the object it stores. By changing what location your variable stores, you can no longer access previous location but it's still there. So before changing variables that point to an object you won't use anymore, destroy the object (location in this case).
     
  11. Maker

    Maker

    Joined:
    Mar 6, 2006
    Messages:
    9,174
    Resources:
    17
    Maps:
    2
    Spells:
    14
    Tutorials:
    1
    Resources:
    17
    Set point = position of triggering unit
    Set point = position of target unit
    Remove point
    ^Leaks

    Set point = position of unit
    Create unit at point
    Move unit to point
    Remove point
    ^No leak
     
  12. plumsy460

    plumsy460

    Joined:
    Oct 2, 2013
    Messages:
    273
    Resources:
    0
    Resources:
    0
    Holy ship, I didn't expect an answer so fast! :O
    And entire 3 great answers! This is overwhelming.

    Thank you all so much! I hope you will be around for more of my noobish questions :)

    Now I've basicly done it like this:

    A var defines a point/location -> I spawn a unit through the var so it appears on that location -> i remove the location -> define a new location with the same var -> spawn another unit through the var -> delete the location once again

    So I guess it doesn't matter how much or what I spawn at the location through the var? As long as the var doesn't change position I can always delete the location with one action?
     
    Last edited: Oct 3, 2013
  13. Metalbear

    Metalbear

    Joined:
    Jan 15, 2010
    Messages:
    153
    Resources:
    2
    Template:
    2
    Resources:
    2
    Vas ist correct! As long as you dont change the value association, you will not create any more memory faults. And dont remove every time the point, or it wont work the next time and you will need to create it once again!
    Every time you chose a location, its like WC3 editor is auto-creating hidden vars and thats why you need to associate em to your own var, so you can clear em... Sounds dull and complicated?
     
  14. plumsy460

    plumsy460

    Joined:
    Oct 2, 2013
    Messages:
    273
    Resources:
    0
    Resources:
    0
    Not at all, sounds very good thanks^^

    I feel I have a good understanding of it now. I even did some testing just to be clear.

    I was wondering about special effects attached to units. I'm aware you need to destroy special effects, but does it leak any points like "create special effect at point" does?
     
  15. WaterKnight

    WaterKnight

    Joined:
    Aug 18, 2009
    Messages:
    4,035
    Resources:
    5
    Maps:
    1
    Tutorials:
    4
    Resources:
    5
    "Special effect at point" does not create any location. But you need to pass one and may do so by using a function that creates a new one.
     
  16. Daffa

    Daffa

    Joined:
    Jan 30, 2013
    Messages:
    8,201
    Resources:
    31
    Packs:
    1
    Maps:
    9
    Spells:
    18
    Tutorials:
    3
    Resources:
    31
    UMSWE never bugs, at least the 5.0 Version.
    Only note is to never use triggers under Compatibility Category
     
  17. plumsy460

    plumsy460

    Joined:
    Oct 2, 2013
    Messages:
    273
    Resources:
    0
    Resources:
    0
    If I define: Var = (Random unit from Unit Group) and I set the unit group to (Units within range of a Point).
    Would that leak both a group and a point?
    Do I solve that by creating a Var for both UG and Point and destroying them afterwards?
     
  18. edo494

    edo494

    Joined:
    Apr 16, 2012
    Messages:
    3,846
    Resources:
    5
    Spells:
    1
    JASS:
    4
    Resources:
    5
    yes, because if you choose from the gui menu, you pretty much always create new group
    every time you see Point(…, …), it must be assigned to var or it will leak

    you dont technically need group var however, you could use
    Custom Script: set bj_wantDestroyGroup = true
    and that should clean the group after the enumeration you do
     
  19. plumsy460

    plumsy460

    Joined:
    Oct 2, 2013
    Messages:
    273
    Resources:
    0
    Resources:
    0
    Does that destroy the last created unit group or how does it work exacly?
     
  20. TriggerHappy

    TriggerHappy

    Code Moderator

    Joined:
    Jun 23, 2007
    Messages:
    3,793
    Resources:
    22
    Spells:
    11
    Tutorials:
    2
    JASS:
    9
    Resources:
    22
    Take a look at this blizzard function.

    Code (vJASS):
    function ForGroupBJ takes group whichGroup, code callback returns nothing
        // If the user wants the group destroyed, remember that fact and clear
        // the flag, in case it is used again in the callback.
        local boolean wantDestroy = bj_wantDestroyGroup
        set bj_wantDestroyGroup = false

        call ForGroup(whichGroup, callback)

        // If the user wants the group destroyed, do so now.
        if (wantDestroy) then
            call DestroyGroup(whichGroup)
        endif
    endfunction


    See, if you set
    bj_wantDestroyGroup
    to true and call
    ForGroupBJ
    then it will destroy the group.

    I think it would be best to avoid this way of destroying groups, though.