• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[Trigger] Leak Question

Status
Not open for further replies.
Level 9
Joined
Dec 26, 2010
Messages
475
Hi guys, i just wanna ask if my trigger leaks :thumbs_up: :prazz:

  • Select Hero Random
    • Events
      • Time - HeroPick_Timer expires
    • Conditions
    • Actions
      • Countdown Timer - Destroy HeroPick_TimerWindow
      • Player Group - Pick every player in Map_Players[0] and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Player_Already_Picked[(Player number of (Picked player))] Equal to 0
            • Then - Actions
              • Set Random_Hero = (Random integer number between 1 and RandomHeroes)
              • Unit - Create 1 Heroes[Random_Hero] for (Picked player) at (Center of Hero Tavern Out <gen>) facing Default building facing degrees
              • Quest - Display to (All enemies of (Picked player)) the Hint message: (A player has randomed + (Name of (Last created unit)))
              • Set Player_Already_Picked[(Player number of (Picked player))] = (Player_Already_Picked[(Player number of (Picked player))] + 1)
              • Custom script: call DestroyForce(udg_Map_Players[0])
              • Player Group - Pick every player in Map_Players[0] and do (Actions)
                • Loop - Actions
                  • Player - Make (Unit-type of (Last created unit)) Unavailable for training/construction by (Picked player)
                  • Custom script: call DestroyForce(udg_Map_Players[0])
            • Else - Actions
 
Level 9
Joined
Dec 26, 2010
Messages
475
Put the DestroyForce after the loop... coz right now, ur destroying it while ur still using it...
Thanks +Rep

and you leak the position: Center of Hero Tavern Out <gen>
no it wont leak because i have:

  • Hero Pick Team 1
    • Events
      • Unit - A unit enters Hero Tavern Out <gen>
    • Conditions
      • ((Triggering unit) belongs to an ally of Player 1 (Red)) Equal to True
    • Actions
      • Unit - Move (Entering unit) instantly to (Center of Hero Teleport When Pick T1 <gen>)
      • Camera - Pan camera for (Owner of (Buying unit)) to (Center of Hero Teleport When Pick T1 <gen>) over 2.00 seconds

  • Hero Pick Team 2
    • Events
      • Unit - A unit enters Hero Tavern Out <gen>
    • Conditions
      • ((Triggering unit) belongs to an ally of Player 7 (Green)) Equal to True
    • Actions
      • Unit - Move (Entering unit) instantly to (Center of Hero Teleport When Pick T2 <gen>)
      • Camera - Pan camera for (Owner of (Buying unit)) to (Center of Hero Teleport When Pick T2 <gen>) over 2.00 seconds
 
it leaks...

each time you call this: Unit - Create 1 Heroes[Random_Hero] for (Picked player) at (Center of Hero Tavern Out <gen>) facing Default building facing degrees, a location is created at [Center of Hero Tavern Out <gen>] which stays in the memory forever...

The positions on those triggers leak too...

you should always destroy created locations/points after you use them...
 
Level 8
Joined
Dec 12, 2010
Messages
280
Yes all the triggers above have region leaks. When you refer to a region or point on a map the game creates a location ID that should be removed so that ID can be recycled or used over freeing up a small amount of memory.

Just set a Point variable to the location used before the action and remove it at the end of the trigger.

Also if you use coordinates > x,y,z this doesn't leak.
Like point 0,0,0 for center of map. No leak.
 
Level 9
Joined
Dec 26, 2010
Messages
475
it leaks...

each time you call this: Unit - Create 1 Heroes[Random_Hero] for (Picked player) at (Center of Hero Tavern Out <gen>) facing Default building facing degrees, a location is created at [Center of Hero Tavern Out <gen>] which stays in the memory forever...

The positions on those triggers leak too...

you should always destroy created locations/points after you use them...
eh, how about this? :)

  • Select Hero Random
    • Events
      • Time - HeroPick_Timer expires
    • Conditions
    • Actions
      • Countdown Timer - Destroy HeroPick_TimerWindow
      • Player Group - Pick every player in Map_Players[0] and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Player_Already_Picked[(Player number of (Picked player))] Equal to 0
            • Then - Actions
              • Set Random_Hero_Location = (Center of Hero Tavern Out <gen>)
              • Set Random_Hero = (Random integer number between 1 and RandomHeroes)
              • Unit - Create 1 Heroes[Random_Hero] for (Picked player) at Random_Hero_Location facing Default building facing degrees
              • Quest - Display to (All enemies of (Picked player)) the Hint message: (A player has randomed + (Name of (Last created unit)))
              • Set Player_Already_Picked[(Player number of (Picked player))] = (Player_Already_Picked[(Player number of (Picked player))] + 1)
              • Custom script: call DestroyForce(udg_Map_Players[0])
              • Custom script: call RemoveLocation(udg_Random_Hero_Location)
              • Player Group - Pick every player in Map_Players[0] and do (Actions)
                • Loop - Actions
                  • Player - Make (Unit-type of (Last created unit)) Unavailable for training/construction by (Picked player)
              • Custom script: call DestroyForce(udg_Map_Players[0])
            • Else - Actions
 
That doesn't leak, but that should be this:
  • Select Hero Random
    • Events
      • Time - HeroPick_Timer expires
    • Conditions
    • Actions
      • Countdown Timer - Destroy HeroPick_TimerWindow
      • Player Group - Pick every player in Map_Players[0] and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Player_Already_Picked[(Player number of (Picked player))] Equal to 0
            • Then - Actions
              • Set Random_Hero_Location = (Center of Hero Tavern Out <gen>)
              • Set Random_Hero = (Random integer number between 1 and RandomHeroes)
              • Unit - Create 1 Heroes[Random_Hero] for (Picked player) at Random_Hero_Location facing Default building facing degrees
              • Quest - Display to (All enemies of (Picked player)) the Hint message: (A player has randomed + (Name of (Last created unit)))
              • Set Player_Already_Picked[(Player number of (Picked player))] = (Player_Already_Picked[(Player number of (Picked player))] + 1)
              • Custom script: call RemoveLocation(udg_Random_Hero_Location)
              • Player Group - Pick every player in Map_Players[0] and do (Actions)
                • Loop - Actions
                  • Player - Make (Unit-type of (Last created unit)) Unavailable for training/construction by (Picked player)
            • Else - Actions
      • ------- make sure it is outside of the loop -------
      • Custom script: call DestroyForce(udg_Map_Players[0])
The functions "Pick every blahblah in..." do not leak unless you are creating a handle in the process. When you use "Pick every blahblah in..." with a global, it does not leak as it is just executing the functions for the defined force. The code you posted won't work because it will destroy the force before the construction modifier, and it will also constantly destroy a null force, which is not needed. :p Thus, simply move it out of the loops and it should work fine, with no leaks.
 
Level 9
Joined
Dec 26, 2010
Messages
475
That doesn't leak, but that should be this:
  • Select Hero Random
    • Events
      • Time - HeroPick_Timer expires
    • Conditions
    • Actions
      • Countdown Timer - Destroy HeroPick_TimerWindow
      • Player Group - Pick every player in Map_Players[0] and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Player_Already_Picked[(Player number of (Picked player))] Equal to 0
            • Then - Actions
              • Set Random_Hero_Location = (Center of Hero Tavern Out <gen>)
              • Set Random_Hero = (Random integer number between 1 and RandomHeroes)
              • Unit - Create 1 Heroes[Random_Hero] for (Picked player) at Random_Hero_Location facing Default building facing degrees
              • Quest - Display to (All enemies of (Picked player)) the Hint message: (A player has randomed + (Name of (Last created unit)))
              • Set Player_Already_Picked[(Player number of (Picked player))] = (Player_Already_Picked[(Player number of (Picked player))] + 1)
              • Custom script: call RemoveLocation(udg_Random_Hero_Location)
              • Player Group - Pick every player in Map_Players[0] and do (Actions)
                • Loop - Actions
                  • Player - Make (Unit-type of (Last created unit)) Unavailable for training/construction by (Picked player)
            • Else - Actions
      • ------- make sure it is outside of the loop -------
      • Custom script: call DestroyForce(udg_Map_Players[0])
The functions "Pick every blahblah in..." do not leak unless you are creating a handle in the process. When you use "Pick every blahblah in..." with a global, it does not leak as it is just executing the functions for the defined force. The code you posted won't work because it will destroy the force before the construction modifier, and it will also constantly destroy a null force, which is not needed. :p Thus, simply move it out of the loops and it should work fine, with no leaks.
Thank you! +Rep
 
Status
Not open for further replies.
Top