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

    Magtheridon96

    Joined:
    Dec 12, 2008
    Messages:
    6,006
    Resources:
    26
    Maps:
    1
    Spells:
    8
    Tutorials:
    7
    JASS:
    10
    Resources:
    26
    Depends.
    If this unit is a dummy, then you might as well remove it when you're not using it anymore.
     
  2. Darklycan51

    Darklycan51

    Joined:
    Jan 12, 2011
    Messages:
    1,325
    Resources:
    3
    Maps:
    3
    Resources:
    3
    i always wondered something if you get tauren chieftain in a Melee map and start spamming shockwave in a mana fountain will it start lagging?...
     
  3. Maltheo2005

    Maltheo2005

    Joined:
    Dec 12, 2012
    Messages:
    96
    Resources:
    0
    Resources:
    0
    This is what I've been looking for. Thank you! :D
     
  4. CoLd Bon3

    CoLd Bon3

    Joined:
    Aug 8, 2010
    Messages:
    948
    Resources:
    4
    Spells:
    4
    Resources:
    4
    Am... i wasn't able to find if this was answered before but... will there be a leak when i remove a unit with "Unit - Add generic expiration timer"? Will the unit leave a leak upon it's removal by the action? I know that unit leaks are pretty tricky..
    Btw, when the generic expiration timer ends, the unit is removed from the game or simply dies as if the "Unit - Kill unit" action was used?

    P.S. Sorry if this was answered before. If it has, please give me a link to the post.
     
  5. Maker

    Maker

    Joined:
    Mar 6, 2006
    Messages:
    9,193
    Resources:
    17
    Maps:
    2
    Spells:
    14
    Tutorials:
    1
    Resources:
    17
    I tested with creating 12000 units and adding expiration timer. I saw no major leaks anyway. If there was a leak it was very small. Don't worry about it.

    I took 4 data points, at 4k, 6k, 8k and 10k. After pausing the test for a while and checking the memory reseved, it was exactly 94352 K at all data points.
     
    Last edited: Jan 4, 2013
  6. CoLd Bon3

    CoLd Bon3

    Joined:
    Aug 8, 2010
    Messages:
    948
    Resources:
    4
    Spells:
    4
    Resources:
    4
    Hm... i can remember that i've seen you saying this somewhere. Perhaps i have asked you before but i have forgot...
    Thanks a lot, anyways! :smile:
     
  7. Metalbear

    Metalbear

    Joined:
    Jan 15, 2010
    Messages:
    153
    Resources:
    2
    Template:
    2
    Resources:
    2
    I am working on a map in which the main use is with groups who store units for different purposes, like dead units or teamed units etc. I wonder if leaks make it crash at all or the wc3 engine just cant handle it, but thats different question. So creating a group and destroying it makes it not leak, but:
    1. What if I create a group and keep "picking every unit" from the same group with out destroying it? Is this leaking?
    2. If it doesnt, then what if I add or remove units by some conditions in that group? Does that create some how like a new leaky memory or?

    I am using groups, so I wont need to re-pick and re-check each unit on the map. I have seen that this way its more cpu friendly. Its a very good way on larger and even larger maps. I expect answer and hopefully this wont leak ... :(

    And last question ...
    Usually when Im kicked out of WC3 with errors like "out of memory" and such, it means the map leaked allot. What if the game kicks you out, with out even saying the error reason? Does that means the map leaked?
     
  8. Maker

    Maker

    Joined:
    Mar 6, 2006
    Messages:
    9,193
    Resources:
    17
    Maps:
    2
    Spells:
    14
    Tutorials:
    1
    Resources:
    17
    Those should not leak. Note that if you destroy a group, or remove a unit, you should null the variable right away.

    Dead/removed units aren't automatically removed from a group I've heard.

    It could be a trigger that causes infnite loop or some other faulty trigger, not necessarily leaks.
     
  9. Metalbear

    Metalbear

    Joined:
    Jan 15, 2010
    Messages:
    153
    Resources:
    2
    Template:
    2
    Resources:
    2
    So first I have to revive the hero and AFTER THAT to remove him from living and add him to grave. Ok tnx for this info.
    Also you meant "destroy udg_var" and then with gui to make "set var = noone/0" etc. with null? Wont that completely screw the saved group if I null it after I remove a unit? -.- Im asking, cause thats the only way to actually keep a track of which hero is "dead". Regions seem to be somehow faulty for picking and destroying in groups.
     
  10. Maker

    Maker

    Joined:
    Mar 6, 2006
    Messages:
    9,193
    Resources:
    17
    Maps:
    2
    Spells:
    14
    Tutorials:
    1
    Resources:
    17
    Don't destroy the group if you need it later. No need to destroy it if you're just adding/removing units.

    If you are using temporary groups, then do this:
    set group = Units within range matching...
    *do things wih group*
    call DestroyGroup(group)
    set group = null
     
  11. Retarded_Hobo

    Retarded_Hobo

    Joined:
    Nov 27, 2012
    Messages:
    82
    Resources:
    0
    Resources:
    0
    Do I need to destroy these triggers? Set the actions into a variable?

    Code (vJASS):

    function GM_GodMode_Exit takes nothing returns nothing
        call DisableTrigger(GetTriggeringTrigger())
        call DisableTrigger(udg_t_godmode[1])
        call DisableTrigger(udg_t_godmode[2])
        call DisableTrigger(udg_t_godmode[3])
        call DisableTrigger(udg_t_godmode[4])
        call DisableTrigger(udg_t_godmode[5])
        call DisableTrigger(udg_t_godmode[6])
        call DisableTrigger(udg_t_godmode[7])
        call DisableTrigger(udg_t_godmode[8])
        call DisableTrigger(udg_t_godmode[9])
        call DisableTrigger(udg_t_godmode[10])
        call DisableTrigger(udg_t_godmode[11])
        call DisableTrigger(udg_t_godmode[12])
        call DisableTrigger(udg_t_godmode[13])
        call DisableTrigger(udg_t_godmode[14])

        call SetPlayerHandicap(udg_God,100.00*0.01)
        call EnableTrigger(gg_trg_God_Mode)
        call DisableTrigger(gg_trg_Restart)
        call DisableTrigger(gg_trg_MM_Restart)
        call DisplayTextToForce(bj_FORCE_ALL_PLAYERS,(udg_PlayerName[GetPlayerId(udg_God)+1]+" has disabled God Mode."))
    endfunction
    //===========================================================================
    function InitTrig_God_Mode takes nothing returns nothing
        local integer i=1
        set gg_trg_God_Mode=CreateTrigger()
       
        loop
            exitwhen i>12
            call TriggerRegisterPlayerChatEvent(gg_trg_God_Mode,Player(i),"-godmode",true)
            set i=i+1
        endloop
       
        call TriggerAddCondition(gg_trg_God_Mode,Condition(function Trig_God_Mode_Conditions))
        call TriggerAddAction(gg_trg_God_Mode,function Trig_God_Mode_Actions)
    endfunction

    function God_Mode_Commands takes nothing returns nothing
        set udg_t_godmode[1]=CreateTrigger()
        call TriggerRegisterPlayerChatEvent(udg_t_godmode[1],udg_God,"-control",true)
        call TriggerAddAction(udg_t_godmode[1],function GM_Control)
       
        set udg_t_godmode[2]=CreateTrigger()
        call TriggerRegisterPlayerChatEvent(udg_t_godmode[2],udg_God,"-controloff",true)
        call TriggerAddAction(udg_t_godmode[2],function GM_ControlOff)
       
        set udg_t_godmode[3]=CreateTrigger()
        call TriggerRegisterPlayerChatEvent(udg_t_godmode[3],udg_God,"-teamshare",false)
        call TriggerAddAction(udg_t_godmode[3],function GM_TeamShare)
       
        set udg_t_godmode[4]=CreateTrigger()
        call TriggerRegisterPlayerChatEvent(udg_t_godmode[4],udg_God,"-teamremove",false)
        call TriggerAddAction(udg_t_godmode[4],function GM_TeamShareOff)
       
        set udg_t_godmode[5]=CreateTrigger()
        call TriggerRegisterPlayerChatEvent(udg_t_godmode[5],udg_God,"-ally",false)
        call TriggerAddAction(udg_t_godmode[5],function GM_Ally)
       
        set udg_t_godmode[6]=CreateTrigger()
        call TriggerRegisterPlayerChatEvent(udg_t_godmode[6],udg_God,"-enemy",false)
        call TriggerAddAction(udg_t_godmode[6],function GM_Enemy)
       
        set udg_t_godmode[7]=CreateTrigger()
        call TriggerRegisterPlayerChatEvent(udg_t_godmode[7],udg_God,"-level",false)
        call TriggerAddAction(udg_t_godmode[7],function GM_Level)
       
        set udg_t_godmode[8]=CreateTrigger()
        call TriggerRegisterPlayerChatEvent(udg_t_godmode[8],udg_God,"-vision",true)
        call TriggerAddAction(udg_t_godmode[8],function GM_Vision)    
       
        set udg_t_godmode[9]=CreateTrigger()
        call TriggerRegisterPlayerChatEvent(udg_t_godmode[9],udg_God,"-visionoff",true)
        call TriggerAddAction(udg_t_godmode[9],function GM_VisionOff)
       
        set udg_t_godmode[10]=CreateTrigger()
        call TriggerRegisterPlayerChatEvent(udg_t_godmode[10],udg_God,"-destroyall",true)
        call TriggerAddAction(udg_t_godmode[10],function GM_DestroyAll)  
       
        set udg_t_godmode[11]=CreateTrigger()
        call TriggerRegisterPlayerChatEvent(udg_t_godmode[11],udg_God,"-reviveall",true)
        call TriggerAddAction(udg_t_godmode[11],function GM_ReviveAll)      
       
        set udg_t_godmode[12]=CreateTrigger()
        call TriggerRegisterPlayerChatEvent(udg_t_godmode[12],udg_God,"-day",true)
        call TriggerAddAction(udg_t_godmode[12],function GM_Day)        
       
        set udg_t_godmode[13]=CreateTrigger()
        call TriggerRegisterPlayerChatEvent(udg_t_godmode[13],udg_God,"-night",true)
        call TriggerAddAction(udg_t_godmode[13],function GM_Night)        
         
        set udg_t_godmode[14]=CreateTrigger()
        call TriggerRegisterPlayerEvent(udg_t_godmode[14],udg_God,EVENT_PLAYER_END_CINEMATIC)
        call TriggerAddAction(udg_t_godmode[14],function GM_Cooldown)  
       
        set udg_t_godmode[15]=CreateTrigger()
        call TriggerRegisterPlayerChatEvent(udg_t_godmode[15],udg_God,"-pe3komode",true)
        call TriggerAddAction(udg_t_godmode[15],function GM_GodMode_Exit)
    endfunction
     
  12. kkots

    kkots

    Joined:
    Jun 21, 2007
    Messages:
    534
    Resources:
    0
    Resources:
    0
    If you destroy the trigger, it won't work. If you nullify variables, you won't be able to reference the trigger.

    To remove the memory leak, first destroy the trigger and then nullify variables referencing it.

    If you are going to reference to the trigger later, do not bother with memory leaks, removing it, etc.
     
  13. StormChaser

    StormChaser

    Joined:
    Jan 28, 2013
    Messages:
    91
    Resources:
    0
    Resources:
    0
    I suppose this might be a bit off-topic but, did you make WarChasers? I played that map with a friend on LAN! We didn't even finish 1/4 of the map before we were killed, heh. I did take a look at the triggers (just looking! I thought it was an official map like BlizzardTD or Death Sheep! I was just curios) and I noticed those trap triggers. I thought they looked easy to code, easier than some of the Damage Area with Dummy I have seen here and there. Knowing that it's your trigger now... should I refrain from using it in my own maps or give you credit somehow? (Tbh when I first started making my own traps my thoughts were similar but I wasn't able to make it work.)

    Oh and to stay on-topic I have a query (or two):
    I don't know if this has been answered before but if I have to use Pick Unit of Type or Pan Camera, what's the best way of doing it? Should I use variables and null them or is there some work around?
    Preferably for a new GUI programmer like me.

    Another thing, I got this trigger were you need to kill all units in a Unit Group. For the Quest to work I use a Pick every unit in Region action and add them to the Unit group. The player needs to kill all the Units in the group in order to complete the quest (which caused problems when I used Ghouls as attackers... they harvested the trees and returned to their Necropolis :vw_unimpressed:) How should I do to stop it from possibly leaking?

    • MainQuest Undead forces
      • Events
        • Unit - A unit owned by Player 3 (Teal) Dies
      • Conditions
        • (All units of CSundeadForces are dead) Equal to True
      • Actions
        • Trigger - Turn off (This trigger)
        • Game - Display to HumanArmy the text: Soldier: Return to ...
        • Quest - Mark SearchUndeadReq as Completed
        • Quest - Display to HumanArmy the Quest Requirement message: Quest requirment co...
        • Wait 2.00 seconds
        • Quest - Change the title of ScoutTown to Press forward
        • Quest - Change the description of ScoutTown to The perimeter is sa...
        • Quest - Create a quest requirement for ScoutTown with the description Scout the northern ...
        • Set NorthScoutReq = (Last created quest requirement)
        • Quest - Display to HumanArmy the Quest Update message: Update: Continue th...
        • Quest - Flash the quest dialog button
     
  14. Vladadamm

    Vladadamm

    Joined:
    Apr 19, 2011
    Messages:
    1,255
    Resources:
    9
    Maps:
    5
    Spells:
    3
    Tutorials:
    1
    Resources:
    9
    Where do you set the group ?
     
  15. StormChaser

    StormChaser

    Joined:
    Jan 28, 2013
    Messages:
    91
    Resources:
    0
    Resources:
    0
    I checked the triggers and maybe I was a bit inefficient with the group creating.

    Here are the trigger(s):
    • Scout the town Create
      • Events
        • Destructible - Rock Chunks 0000 <gen> dies
      • Conditions
      • Actions
        • Quest - Create a Required quest titled Scout the town with the description We haven't heard fr..., using icon path ReplaceableTextures\PassiveButtons\PASBTNPillage.blp
        • Set ScoutTown = (Last created quest)
        • Quest - Create a quest requirement for ScoutTown with the description Go to the east to f...
        • Set ScoutTownReq = (Last created quest requirement)
        • Quest - Flash the quest dialog button
        • Quest - Display to HumanArmy the Quest Discovered message: Discovered quest : ...
        • Quest - Display to HumanArmy the Quest Requirement message: >> Quest requirment...
        • Wait 15.00 seconds
        • Quest - Display to HumanArmy the Hint message: Build an army first...
        • Destructible - Destroy Gate (Vertical) 0252 <gen>
        • Unit Group - Pick every unit in (Units in Arrival2SF <gen> owned by Player 3 (Teal)) and do (Unit Group - Add (Picked unit) to SFundeadforce)
        • Unit Group - Pick every unit in (Units in Silver Fall <gen> owned by Player 3 (Teal)) and do (Unit Group - Add (Picked unit) to SFundeadforce)

    N.B this was a pre-patch map (it was version 1.00 for RoC and 1.07 for TFT) and therefore my possibilities were limited. I used the Destructible Kill event because when you get to a certain region on the map, the destructible is killed (via trigger) and this trigger runs. It's quite complicated. First you get a Dialog on Game Time and when you had made your choice an new trigger activates and it kills the Rock Chunks.

    Edit.2: This trigger lies between the previously posted triggers:
    • ScoutSF arrival
      • Events
        • Unit - A unit enters Arrival2SF <gen>
      • Conditions
        • ((Owner of (Entering unit)) Equal to Player 1 (Red)) or ((Owner of (Entering unit)) Equal to Player 2 (Blue))
      • Actions
        • Trigger - Turn off (This trigger)
        • Game - Display to HumanArmy the text: Soldier: Light have...
        • Quest - Mark ScoutTownReq as Completed
        • Quest - Display to HumanArmy the Quest Requirement message: Quest requirment co...
        • Quest - Create a quest requirement for ScoutTown with the description Destroy the undeads
        • Set SFkillUndeads = (Last created quest requirement)
        • Quest - Display to HumanArmy the Quest Requirement message: New quest requirmen...


    • ScoutSF kill
      • Events
        • Unit - A unit owned by Player 3 (Teal) Dies
      • Conditions
        • (All units of SFundeadforce are dead) Equal to True
      • Actions
        • Trigger - Turn off (This trigger)
        • Game - Display to HumanArmy the text: Soldier: We won!
        • Quest - Mark SFkillUndeads as Completed
        • Quest - Display to HumanArmy the Quest Requirement message: Quest requirment co...
        • Wait 2.00 seconds
        • Quest - Change the title of ScoutTown to Search for more und...
        • Quest - Change the description of ScoutTown to Silver Fall has fal...
        • Quest - Create a quest requirement for ScoutTown with the description Continue the search
        • Set SearchUndeadReq = (Last created quest requirement)
        • Quest - Create a Optional quest titled Search for survivor... with the description There's a slight ch..., using icon path ReplaceableTextures\CommandButtons\BTNFarSight.blp
        • Set SFsurvivors = (Last created quest)
        • Quest - Create a quest requirement for SFsurvivors with the description Search the nearby a...
        • Set SurvSearchReq = (Last created quest requirement)
        • Quest - Display to HumanArmy the Quest Update message: Update: Scout the t...
        • Quest - Display to HumanArmy the Quest Discovered message: A new quest has bee...
        • Quest - Flash the quest dialog button
        • Trigger - Turn on CountrySide set up <gen>
        • Trigger - Turn on Side help a knight <gen>


    • CountrySide set up
      • Events
        • Unit - A unit enters Region 012 <gen>
      • Conditions
        • (SFkillUndeads is completed) Equal to True
      • Actions
        • Trigger - Turn off (This trigger)
        • Unit Group - Pick every unit in (Units in Mine Force <gen> owned by Player 3 (Teal)) and do (Unit Group - Add (Picked unit) to CSundeadForces)
        • Unit Group - Pick every unit in (Units in KeyEnter <gen> owned by Player 3 (Teal)) and do (Unit Group - Add (Picked unit) to CSundeadForces)
        • Trigger - Turn on MainQuest Undead forces <gen>


    • MainQuest Undead forces
      • Events
        • Unit - A unit owned by Player 3 (Teal) Dies
      • Conditions
        • (All units of CSundeadForces are dead) Equal to True
      • Actions
        • Trigger - Turn off (This trigger)
        • Game - Display to HumanArmy the text: Soldier: Return to ...
        • Quest - Mark SearchUndeadReq as Completed
        • Quest - Display to HumanArmy the Quest Requirement message: Quest requirment co...
        • Wait 2.00 seconds
        • Quest - Change the title of ScoutTown to Press forward
        • Quest - Change the description of ScoutTown to The perimeter is sa...
        • Quest - Create a quest requirement for ScoutTown with the description Scout the northern ...
        • Set NorthScoutReq = (Last created quest requirement)
        • Quest - Display to HumanArmy the Quest Update message: Update: Continue th...
        • Quest - Flash the quest dialog button


    I believe I did that because the quest is a two-parter; first you kill all undead forces in the town and then you kill all undead forces on the country side. It can probably get more effective.
    Edit 3: I just realized that it's in fact two different groups. One for the town "SFundeadForce" and one for the country side "CSundeadForce". Both might be leaking however.
     
    Last edited: Feb 2, 2013
  16. Vladadamm

    Vladadamm

    Joined:
    Apr 19, 2011
    Messages:
    1,255
    Resources:
    9
    Maps:
    5
    Spells:
    3
    Tutorials:
    1
    Resources:
    9
    • Unit Group - Pick every unit in (Units in Arrival2SF <gen> owned by Player 3 (Teal)) and do (Unit Group - Add (Picked unit) to SFundeadforce)
    • Unit Group - Pick every unit in (Units in Silver Fall <gen> owned by Player 3 (Teal)) and do (Unit Group - Add (Picked unit) to SFundeadforce)

    Those two groups leak. Put "set bj_wantDestroyGroup = true" after those, like this :
    • Unit Group - Pick every unit in (Units in Arrival2SF <gen> owned by Player 3 (Teal)) and do (Unit Group - Add (Picked unit) to SFundeadforce)
    • Custom script : set bj_wantDestroyGroup = true
    • Unit Group - Pick every unit in (Units in Silver Fall <gen> owned by Player 3 (Teal)) and do (Unit Group - Add (Picked unit) to SFundeadforce)
    • Custom script : set bj_wantDestroyGroup = true
     
  17. Maker

    Maker

    Joined:
    Mar 6, 2006
    Messages:
    9,193
    Resources:
    17
    Maps:
    2
    Spells:
    14
    Tutorials:
    1
    Resources:
    17
    ^You need to set the bj before, not after :)
     
  18. Vladadamm

    Vladadamm

    Joined:
    Apr 19, 2011
    Messages:
    1,255
    Resources:
    9
    Maps:
    5
    Spells:
    3
    Tutorials:
    1
    Resources:
    9
    True x) I was under medicaments when i wrote it (have broken clavicle...)
     
  19. StormChaser

    StormChaser

    Joined:
    Jan 28, 2013
    Messages:
    91
    Resources:
    0
    Resources:
    0
    I got a quick question about removing leaks.

    If you're going to use the same point multiple times, is it a good idea to have a RemoveLocation call? Or should I leave it as it is and not remove?

    Btw the location is set as a variable at the start of the trigger.

    Another question about special effects:

    The question mark symbol for a quest... should I remove it after I have spoken to the NPC or keep it until the quest is finished, remove special effect and then replace it with the exclamation effect? (Then remove it after I have spoken to the NPC a second time.)
     
  20. Tirlititi

    Tirlititi

    Joined:
    Jul 11, 2010
    Messages:
    396
    Resources:
    12
    Models:
    6
    Maps:
    2
    Spells:
    3
    JASS:
    1
    Resources:
    12
    You can keep your location unreleased as long as you keep using it. However, you must acknowledge that locations and location variables are 2 different things. For instance :
    • Set LocVariable = Center of Region 001
    • Do some stuff with LocVariable
    • Set LocVariable = Center of Region 002
    • Do some other stuff with LocVariable
    • Custom script: call RemoveLocation(udg_LocVariable)

    This leaks because there are 2 different locations involved and the 1st one is not removed.
    If this is clear for you, then you don't have to remove locations between every uses.

    About the special effects, the leak issue is irrelevant in your situation : you must remove the special effect when you don't want to display it anymore, period.
    Special effect's leak occurs mostly for spells, when you use a model that disappears by itself, such as the "Steam Impact" model (which is just an explosion) : it displays its animation and then turns "invisible" (TITS it doesn't display anything anymore), so people may forget to destroy it.