1. The heavens smile on the old faithful. The 16th Techtree Contest has begun.
    Dismiss Notice
  2. The die is cast - the 6th Melee Mapping Contest results have been announced. Onward to the Hive Cup!
    Dismiss Notice
  3. The glory of the 20th Icon Contest is yours for the taking!
    Dismiss Notice
  4. Shoot to thrill, play to kill. Sate your hunger with the 33rd Modeling Contest!
    Dismiss Notice
  5. Do you hear boss music? It's the 17th Mini Mapping Contest!
    Dismiss Notice
  6. 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. deathismyfriend

    deathismyfriend

    Joined:
    Oct 24, 2012
    Messages:
    6,526
    Resources:
    14
    Spells:
    12
    Tutorials:
    2
    Resources:
    14
    only thing is its not that much extra effort to null the variables so y not do it lol. i can understand its not worth going over every one of ur old triggers to do it but when making new ones y not.
     
  2. Magtheridon96

    Magtheridon96

    Joined:
    Dec 12, 2008
    Messages:
    6,003
    Resources:
    26
    Maps:
    1
    Spells:
    8
    Tutorials:
    7
    JASS:
    10
    Resources:
    26
    I never tell people to null globals. I never did and I never will :p
    Only local agents should be nulled at least. You can play it safe and null local handles too of course, but they're not reference counted, so it's not needed really~
     
  3. PurgeandFire

    PurgeandFire

    Code Moderator

    Joined:
    Nov 11, 2006
    Messages:
    7,429
    Resources:
    18
    Icons:
    1
    Spells:
    4
    Tutorials:
    9
    JASS:
    4
    Resources:
    18
    Well, there is a tradeoff for everything. Remember that for every extra character in your code, you are adding a slight boost to the file size and a slight speed decrease. Of course, this is all on a microscopic level, but so is the RAM "leak".

    The main reason why we null locals is because it will allow the handle ID to be recycled. Since that problem doesn't exist with globals, we don't have to really worry about it.

    You can still null globals if you want to, but it is more of a matter of personal preference.
     
  4. MasterTrainer

    MasterTrainer

    Joined:
    Apr 14, 2012
    Messages:
    2,769
    Resources:
    3
    Icons:
    1
    Maps:
    1
    Spells:
    1
    Resources:
    3
    I never got to comment when I first read this tutorial but I mus say this is very helpful for beginners (like I was in the days before)... this will be helpful to a lot of people =)

    @Magtheridon96's earlier post: what happens when someone nulls Globals?
     
  5. edo494

    edo494

    Joined:
    Apr 16, 2012
    Messages:
    3,846
    Resources:
    5
    Spells:
    1
    JASS:
    4
    Resources:
    5
    nothing special, it just nullifies the memory variable is pointing to(the value stored in variable) so if you call some functions which take that type and you pass global, it will not do anything

    Be aware that nullying(I dont know about the y tho) is not the same as destroying the handles
     
  6. MasterTrainer

    MasterTrainer

    Joined:
    Apr 14, 2012
    Messages:
    2,769
    Resources:
    3
    Icons:
    1
    Maps:
    1
    Spells:
    1
    Resources:
    3
    I never knew that info about Globals until now, but I sure know the difference between nulling a handle and destroying it.

    Thanks for answering me =)
     
  7. mikagami

    mikagami

    Joined:
    Aug 9, 2012
    Messages:
    112
    Resources:
    0
    Resources:
    0
    Great !! Very helpful
     
  8. Losam

    Losam

    Joined:
    Mar 27, 2011
    Messages:
    258
    Resources:
    8
    Spells:
    8
    Resources:
    8
    Help

    What this best way to:

    • Create random unit groups.
    • MUI/Loop Spells (for GUI's Users).
    • Create Channel's Spells.
     
  9. MasterTrainer

    MasterTrainer

    Joined:
    Apr 14, 2012
    Messages:
    2,769
    Resources:
    3
    Icons:
    1
    Maps:
    1
    Spells:
    1
    Resources:
    3
    If you want to make MUI spells, there are some tutorials here on Hive.
     
  10. deathismyfriend

    deathismyfriend

    Joined:
    Oct 24, 2012
    Messages:
    6,526
    Resources:
    14
    Spells:
    12
    Tutorials:
    2
    Resources:
    14
    u should also create one group for spell. as creating it every iteration is very inefficient.
    u also wont have to destroy it anymore.
     
  11. MasterTrainer

    MasterTrainer

    Joined:
    Apr 14, 2012
    Messages:
    2,769
    Resources:
    3
    Icons:
    1
    Maps:
    1
    Spells:
    1
    Resources:
    3
    So store units created in the spell in a group var?
     
  12. edo494

    edo494

    Joined:
    Apr 16, 2012
    Messages:
    3,846
    Resources:
    5
    Spells:
    1
    JASS:
    4
    Resources:
    5
    yes, the enumeration is bit heavy operation, but create/destroy unit group is lot more heavy, if you create, fill,, itterate, destroy group every .01 sec it may and most likely will start dropping fps just because of how heavy the create destroy combo is

    you can just add units to the unit group when spell is cast and remove them when the effect of the spell has ended for them, then when the group is empty you should turn off the trigger to prevent useless iterations, but you most likely know that already
     
  13. mckill2009

    mckill2009

    Joined:
    Mar 10, 2009
    Messages:
    4,696
    Resources:
    34
    Maps:
    5
    Spells:
    27
    JASS:
    2
    Resources:
    34
    bj_lastCreatedGroup can be used for instant itineration, so no need to create one group, this usually works but 'might' have problems if someone saved that group then destroys it...
     
  14. MasterTrainer

    MasterTrainer

    Joined:
    Apr 14, 2012
    Messages:
    2,769
    Resources:
    3
    Icons:
    1
    Maps:
    1
    Spells:
    1
    Resources:
    3
    bj_lastCreatedGroup is
    • Unit Group - Last Created Unit Group
    right?
     
  15. mckill2009

    mckill2009

    Joined:
    Mar 10, 2009
    Messages:
    4,696
    Resources:
    34
    Maps:
    5
    Spells:
    27
    JASS:
    2
    Resources:
    34
    bj_lastCreatedGroup is used inside that trigger but it's not that...
     
  16. MasterTrainer

    MasterTrainer

    Joined:
    Apr 14, 2012
    Messages:
    2,769
    Resources:
    3
    Icons:
    1
    Maps:
    1
    Spells:
    1
    Resources:
    3
    Oh I see; thanks for the info :D
     
  17. WaterKnight

    WaterKnight

    Joined:
    Aug 18, 2009
    Messages:
    4,035
    Resources:
    5
    Maps:
    1
    Tutorials:
    4
    Resources:
    5
    Not quite:

     
  18. caleman

    caleman

    Joined:
    Jul 21, 2011
    Messages:
    139
    Resources:
    0
    Resources:
    0
    please upload a map with a spell example, im interesed
     
  19. ScorpioT1000

    ScorpioT1000

    Joined:
    Jun 26, 2013
    Messages:
    43
    Resources:
    0
    Resources:
    0
  20. Daffa

    Daffa

    Joined:
    Jan 30, 2013
    Messages:
    8,205
    Resources:
    31
    Packs:
    1
    Maps:
    9
    Spells:
    18
    Tutorials:
    3
    Resources:
    31
    Sadly that snippet don't compatible with all Vex Jass and thus can't be recommended here.