• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[Trigger] Pick every (Titanic-type unit) and Leak at (position of Iceberg)

Status
Not open for further replies.
Ok, I think I really did something bad to myself. I said, "its ok if it leaks, I can go back and learn to fix it later." Well, that was probably true at first, but like any addiction, I started using more and more. Anyway, most of my problems look like this.
  • Barracks AoS
    • Events
      • Time - Every 25.00 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in (Units owned by Player 1 (Red) of type Barracks) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Life of (Picked unit)) Greater than or equal to 1000.00
              • (Number of living Footman units owned by Player 4 (Purple)) Less than 6
            • Then - Actions
              • Unit - Create 1 Footman for Player 1 (Red) at (Position of (Picked unit)) facing (Center of (Playable map area))
              • Unit - Change ownership of (Last created unit) to Player 4 (Purple) and Retain color
              • Unit - Order (Last created unit) to Attack-Move To (Player 2 (Blue) start location)
              • Animation - Play (Picked unit)'s Stand Work animation
            • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
        • Then - Actions
          • Set UnitGroup = (Last created unit group)
          • Custom script: call DestroyGroup(UnitGroup)
        • Else - Actions
Wait!!! Before you comment, I know how to fix this. My issue is I have about 12 of these buggers and bunches more other leaky things... like this
  • AoS plyr 1
    • Events
      • Time - Every 30.00 seconds of game time
    • Conditions
    • Actions
      • Unit - Create 1 Lordaeron Militia for Player 4 (Purple) at (Player 1 (Red) start location) facing (Center of (Playable map area))
      • Unit - Change ownership of (Last created unit) to Player 4 (Purple) and Retain color
      • Unit - Order (Last created unit) to Attack-Move To (Player 2 (Blue) start location)
      • Unit - Create 1 Lordaeron Militia for Player 4 (Purple) at (Player 1 (Red) start location) facing (Center of (Playable map area))
      • Unit - Change ownership of (Last created unit) to Player 4 (Purple) and Retain color
      • Unit - Order (Last created unit) to Attack-Move To (Player 2 (Blue) start location)
      • Unit - Create 1 Lordaeron Militia for Player 4 (Purple) at (Player 1 (Red) start location) facing (Center of (Playable map area))
      • Unit - Change ownership of (Last created unit) to Player 4 (Purple) and Retain color
      • Unit - Order (Last created unit) to Attack-Move To (Player 2 (Blue) start location)

So my question is... If I'm lazy, is there some leaks that are worse that I must absolutely fix, or is there any easy way to calldestroy/removelocation for all locations and unitgroups periodically? Someone throw me a life boat please, or tell me which leaks I can fix so I make it to Manhattan alive. Oh ya, and there's this one too
  • Hero Select
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Melee Game - Set starting resources (for all players)
      • Melee Game - Create Human starting units for Player 1 (Red) at (Player 1 (Red) start location) (Exclude Heroes)
      • Melee Game - Create Night Elf starting units for Player 2 (Blue) at (Player 2 (Blue) start location) (Exclude Heroes)
      • Game - Set the time of day to 17.00
      • Camera - Lock camera target for Player 1 (Red) to Steelborn 0084 <gen>, offset by (0.00, 0.00) using Default rotation
      • Camera - Lock camera target for Player 2 (Blue) to Druid 0089 <gen>, offset by (0.00, 0.00) using Default rotation
      • Camera - Set Player 1 (Red)'s camera Angle of attack to 365.00 over 0.00 seconds
      • Camera - Set Player 2 (Blue)'s camera Angle of attack to 365.00 over 0.00 seconds
      • Camera - Set Player 1 (Red)'s camera Distance to target to 825.00 over 0.00 seconds
      • Camera - Set Player 2 (Blue)'s camera Distance to target to 825.00 over 0.00 seconds
      • Camera - Set Player 1 (Red)'s camera Height Offset to 475.00 over 0.00 seconds
      • Camera - Set Player 2 (Blue)'s camera Height Offset to 475.00 over 0.00 seconds
      • Environment - Create at (Playable map area) the weather effect Ashenvale Rain (Light)
      • Environment - Turn (Last created weather effect) On
      • Environment - Create at Region 005 <gen> the weather effect Rays Of Moonlight
      • Environment - Turn (Last created weather effect) On
      • Environment - Create at Region 005 <gen> the weather effect Wind (Heavy)
      • Environment - Turn (Last created weather effect) On
      • Environment - Create at Region 006 <gen> the weather effect Wind (Heavy)
      • Environment - Turn (Last created weather effect) On
      • Environment - Create at Region 006 <gen> the weather effect Rays Of Moonlight
      • Environment - Turn (Last created weather effect) On
      • Environment - Set sky to Felwood Sky
      • Floating Text - Create floating text that reads Choose a Hero above Renegade 0135 <gen> with Z offset 40.00, using font size 20.00, color (100.00%, 100.00%, 50.00%), and 50.00% transparency
      • Set FloatingText[1] = (Last created floating text)
      • Floating Text - Change (Last created floating text): Enable permanence
      • Floating Text - Change the lifespan of (Last created floating text) to 5.00 seconds
      • Floating Text - Change the fading age of (Last created floating text) to 4.00 seconds
      • Floating Text - Create floating text that reads Choose a Hero above Night Ranger (Glaive) 0091 <gen> with Z offset 40.00, using font size 20.00, color (100.00%, 100.00%, 50.00%), and 0.00% transparency
      • Set FloatingText[2] = (Last created floating text)
      • Floating Text - Change (Last created floating text): Enable permanence
      • Floating Text - Change the fading age of (Last created floating text) to 4.00 seconds
      • Floating Text - Change the lifespan of (Last created floating text) to 5.00 seconds
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Player 1 (Red) controller) Not equal to User
        • Then - Actions
          • Set ready[1] = 1
          • Unit - Create 1 Valkyrie for Player 1 (Red) at (Player 4 (Purple) start location) facing (Player 1 (Red) start location)
          • Set Hero[1] = (Last created unit)
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Player 2 (Blue) controller) Not equal to User
        • Then - Actions
          • Set ready[2] = 1
          • Unit - Create 1 Demon Hunter for Player 2 (Blue) at (Player 3 (Teal) start location) facing (Center of (Playable map area))
          • Set Hero[2] = (Last created unit)
        • Else - Actions
Since it only runs once then gets turned off, I don't need to destroy all of the enviro fx right?
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
Any leak is important. There's no need to hold memory garbage around to make your map laggy.

This would be the most usefull thing for your problem: http://www.hiveworkshop.com/forums/...0/?prev=search=memory%20leak&d=list&r=20&t=65

Anyway, i still recommend you to learn how to avoid leaks. When i say "avoid" i mean "not even create them".

You can create units using x/y. You can move units using x/y. The ONLY reason to use a Location is to get the Location Z (Height) for triggered parabola stuff and else. Any other location use can be avoided using x/y, therefore, there's no need to clean leaks, since there isn't any leak.

Something similar happens with most of group creations.

You should try to learn some basic JASS: There are some really easy tutorials around there.
 
Any leak is important. There's no need to hold memory garbage around to make your map laggy.

This would be the most usefull thing for your problem: http://www.hiveworkshop.com/forums/...0/?prev=search=memory%20leak&d=list&r=20&t=65

Anyway, i still recommend you to learn how to avoid leaks. When i say "avoid" i mean "not even create them".

You can create units using x/y. You can move units using x/y. The ONLY reason to use a Location is to get the Location Z (Height) for triggered parabola stuff and else. Any other location use can be avoided using x/y, therefore, there's no need to clean leaks, since there isn't any leak.

Something similar happens with most of group creations.

You should try to learn some basic JASS: There are some really easy tutorials around there.

I'm with you on the "don't create them in the first place" bit. But since I already shot myself in the foot, I need to clean it up. The auto-leak-cleaner tool makes sense but I can't tell how it works from reading the instructions. It seems like it just clears variables periodically. This still means I need to create variables for oh, I don't know, a few hundred locations and unit groups. I might be exaggerating but not by much. If I have to create the variables, I might as well use the calldestroy/removelocation script for each one. It wouldn't take much more time after creating each variable. Please tell me that I am mistaken and I can just copy and paste the clean-up tool into a custom script trigger. Anyway, thanks for the answer, it sounds like the best advice.
 
one temp variable can take care of all of ur point leaks. if u stick by the temp variable rule.

also note that using that system is bad practice since u dont fix them urself and wont learn how.
also it makes ur map a lot less efficient.

Now you tell me, lol. I installed it and it did something but the map still got laggy after a while. Please explain this "one temp variable." I want to use it.
 
Level 15
Joined
Oct 18, 2008
Messages
1,591
  • Unit - Create 1 Footman for Player 1 (Red) at (Position of (Picked unit))
Locations leak in an amazing way, so use variables for them and clean them up.

So:
  • Set TempLoc = Position of (Picked unit)
  • Set TempCenter = Center of (Playable map area)
  • Unit - Create 1 Footman for Player 1 (Red) at (TempLoc) facing (TempCenter)
  • Custom script: call RemoveLocation( udg_TempLoc )
  • Custom script: call RemoveLocation( udg_TempCenter )
Also I prefer using Random Angle when creating a unit, since it leaks in no way and costs less performance than calculating the angle from the center of the map (it uses trigonometry as opposed to a simple generic random algorithm)

Same goes for these:

  • Unit - Create 1 Lordaeron Militia for Player 4 (Purple) at (Player 1 (Red) start location) facing (Center of (Playable map area))
  • Unit - Order (Last created unit) to Attack-Move To (Player 2 (Blue) start location)
  • Unit - Create 1 Lordaeron Militia for Player 4 (Purple) at (Player 1 (Red) start location) facing (Center of (Playable map area))
  • Unit - Order (Last created unit) to Attack-Move To (Player 2 (Blue) start location)
  • Unit - Create 1 Lordaeron Militia for Player 4 (Purple) at (Player 1 (Red) start location) facing (Center of (Playable map area))
  • Unit - Change ownership of (Last created unit) to Player 4 (Purple) and Retain color
On every iteration you leak god knows how many points...
 
  • Unit - Create 1 Footman for Player 1 (Red) at (Position of (Picked unit))
Locations leak in an amazing way, so use variables for them and clean them up.

So:
  • Set TempLoc = Position of (Picked unit)
  • Set TempCenter = Center of (Playable map area)
  • Unit - Create 1 Footman for Player 1 (Red) at (TempLoc) facing (TempCenter)
  • Custom script: call RemoveLocation( udg_TempLoc )
  • Custom script: call RemoveLocation( udg_TempCenter )
Also I prefer using Random Angle when creating a unit, since it leaks in no way and costs less performance than calculating the angle from the center of the map (it uses trigonometry as opposed to a simple generic random algorithm)

Same goes for these:

  • Unit - Create 1 Lordaeron Militia for Player 4 (Purple) at (Player 1 (Red) start location) facing (Center of (Playable map area))
  • Unit - Order (Last created unit) to Attack-Move To (Player 2 (Blue) start location)
  • Unit - Create 1 Lordaeron Militia for Player 4 (Purple) at (Player 1 (Red) start location) facing (Center of (Playable map area))
  • Unit - Order (Last created unit) to Attack-Move To (Player 2 (Blue) start location)
  • Unit - Create 1 Lordaeron Militia for Player 4 (Purple) at (Player 1 (Red) start location) facing (Center of (Playable map area))
  • Unit - Change ownership of (Last created unit) to Player 4 (Purple) and Retain color
On every iteration you leak god knows how many points...

Thanks, that pretty useful. I can do that to get rid of my location leaks, but what about unit group leaks? Does this work?
  • Aviary
    • Events
      • Time - Every 60.00 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in (Units owned by Player 1 (Red) of type Gryphon Aviary) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Life of (Picked unit)) Greater than or equal to 1000.00
              • (Number of living Gryphon Rider units owned by Player 4 (Purple)) Less than 4
            • Then - Actions
              • Unit - Create 1 Gryphon Rider for Player 1 (Red) at Sanctum facing (Center of (Playable map area))
              • Unit - Change ownership of (Last created unit) to Player 4 (Purple) and Retain color
              • Unit - Order (Last created unit) to Attack-Move To (Player 2 (Blue) start location)
              • Animation - Play (Picked unit)'s Stand Work animation
            • Else - Actions
      • Unit Group - Remove all units from (Last created unit group)
  • AoS plyr 1
    • Events
      • Time - Every 30.00 seconds of game time
    • Conditions
    • Actions
      • Set TempSL[1] = (Player 1 (Red) start location)
      • Set TempSL[2] = (Player 2 (Blue) start location)
      • Set TempCntr = (Center of (Playable map area))
      • Unit - Create 1 Lordaeron Militia for Player 4 (Purple) at TempSL[1] facing TempCntr
      • Unit - Order (Last created unit) to Attack-Move To TempSL[2]
      • Unit - Create 1 Lordaeron Militia for Player 4 (Purple) at TempSL[1] facing TempCntr
      • Unit - Order (Last created unit) to Attack-Move To (Player 2 (Blue) start location)
      • Unit - Create 1 Lordaeron Militia for Player 4 (Purple) at TempSL[1] facing TempCntr
      • Unit - Order (Last created unit) to Attack-Move To (Player 2 (Blue) start location)
      • Custom script: call RemoveLocation ( udg_TempSL[1] )
      • Custom script: call RemoveLocation ( udg_TempSL[2] )
      • Custom script: call RemoveLocation ( udg_TempCntr )
I used arrays, is that ok?
 
Level 15
Joined
Oct 18, 2008
Messages
1,591
  • Set TempUnitGroup = Units owned by Player 1 (Red) of type Gryphon Aviary
  • Unit Group - Pick every unit in (TempUnitGroup) and do (Actions)
    • Loop - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Life of (Picked unit)) Greater than or equal to 1000.00
          • (Number of living Gryphon Rider units owned by Player 4 (Purple)) Less than 4
        • Then - Actions
          • Unit - Create 1 Gryphon Rider for Player 1 (Red) at Sanctum facing Random Angle
          • Unit - Change ownership of (Last created unit) to Player 4 (Purple) and Retain color
          • Set StartLoc = Player 2 (Blue) start location
          • Unit - Order (Last created unit) to Attack-Move To (StartLoc)
          • Custom script: call RemoveLocation ( udg_StartLoc )
          • Animation - Play (Picked unit)'s Stand Work animation
        • Else - Actions
  • Custom script: call DestroyGroup( udg_TempUnitGroup )
also, stop using "facing (Center of (Playable map area))" it leaks seriously badly. Each time it is run it creates a new point at the middle of the map.
http://www.hiveworkshop.com/forums/triggers-scripts-269/things-leak-35124/
Take a good look, here are every possible leaks listed and the way to resolve them
 
  • Set TempUnitGroup = Units owned by Player 1 (Red) of type Gryphon Aviary
  • Unit Group - Pick every unit in (TempUnitGroup) and do (Actions)
    • Loop - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Life of (Picked unit)) Greater than or equal to 1000.00
          • (Number of living Gryphon Rider units owned by Player 4 (Purple)) Less than 4
        • Then - Actions
          • Unit - Create 1 Gryphon Rider for Player 1 (Red) at Sanctum facing Random Angle
          • Unit - Change ownership of (Last created unit) to Player 4 (Purple) and Retain color
          • Set StartLoc = Player 2 (Blue) start location
          • Unit - Order (Last created unit) to Attack-Move To (StartLoc)
          • Custom script: call RemoveLocation ( udg_StartLoc )
          • Animation - Play (Picked unit)'s Stand Work animation
        • Else - Actions
  • Custom script: call DestroyGroup( udg_TempUnitGroup )
also, stop using "facing (Center of (Playable map area))" it leaks seriously badly. Each time it is run it creates a new point at the middle of the map.
http://www.hiveworkshop.com/forums/triggers-scripts-269/things-leak-35124/
Take a good look, here are every possible leaks listed and the way to resolve them
Wow, I got it, I think. That's going to be a lot of work. I need to destroy every unitgroup and location I used in every trigger. Can you tell me if I can destroy an array variable as demonstrated in my last post (second trigger).

Haha, just looked at it again. I missed a few.

Thanks for taking the time. = rep +
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
"Pick every unit of Type" leaks. You have to pick every unit, and then use an "IF/Then/else" to check the unit type.

I would, in your case, work these triggers one by one. Once you get the hang on it, you'll become really fast. Even faster if you do it in jass.
 
@TO
U can check out my tutorial things a GUIer should know it will help a lot.
Also here is custom script for an arrayed variable
  • Custom script: call RemoveLocation( udg_tempPoint[1])
1 is the index.
Rule of a temp variable is never use a temp variable with a wait or a timer to store the info. Other than that use it in every trigger.
I show how to clean leaks in some of my examples in the tutorial also. That may help u since u will be able to see how they are used
 
@TO
U can check out my tutorial things a GUIer should know it will help a lot.
Also here is custom script for an arrayed variable
  • Custom script: call RemoveLocation( udg_tempPoint[1])
1 is the index.
Rule of a temp variable is never use a temp variable with a wait or a timer to store the info. Other than that use it in every trigger.
I show how to clean leaks in some of my examples in the tutorial also. That may help u since u will be able to see how they are used

Thanks for the reply, but already I read your tutorial last night, and stayed up until 5am working on it. I think I got it now. By the way, that tutorial is the best I have read so far. Its much better than "Things that leak." I read several before posting yesterday. Also, I'm glad my index script works. As you can see in my trigger above, I was using
  • Custom script: call RemoveLocation ( udg_TempPoint[2] )
etc. already. Thank you for the confirmation, I wasn't sure it really worked. I was told it would not work so I was going to change it. You have saved my life. I think the ship will sail and we will make it through these icy waters after all. Thank you again and again!
 
Last edited:
Status
Not open for further replies.
Top