• 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] Memory Leaks?

Status
Not open for further replies.
Level 4
Joined
Aug 20, 2004
Messages
65
I just copied a GUI Wild Axes from a DotA spell pack into another map but after one use there was a drop in the FPS. More uses = more lag, so I'm guessing there are memory leaks. I'm on a mac, so no leak dectecting software for me. Can some one give this the once-over?

  • Wild Axe Initialisation
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Wild Axe
    • Actions
      • Set WildAxe_Caster = (Triggering unit)
      • Set WildAxe_Caster_Loc = (Position of WildAxe_Caster)
      • Set WildAxe_Target_Loc = (Target point of ability being cast)
      • Set WildAxe_Angle = (Angle from WildAxe_Caster_Loc to WildAxe_Target_Loc)
      • Set WildAxe_Distance = (Distance between WildAxe_Caster_Loc and WildAxe_Target_Loc)
      • Set WildAxe_Interval = ((WildAxe_Distance / 25.00) + ((15.00 / 1000.00) x WildAxe_Distance))
      • Unit - Create 1 Wild Axe Dummy (Level 1) for (Owner of WildAxe_Caster) at WildAxe_Caster_Loc facing WildAxe_Angle degrees
      • Set WildAxe_Dummy[1] = (Last created unit)
      • Unit - Create 1 Wild Axe Dummy (Level 1) for (Owner of WildAxe_Caster) at WildAxe_Caster_Loc facing WildAxe_Angle degrees
      • Set WildAxe_Dummy[2] = (Last created unit)
      • Countdown Timer - Start WildAxe_Timer as a Repeating timer that will expire in 0.04 seconds
Second Trigger

  • Wild Axe Movement
    • Events
      • Time - WildAxe_Timer expires
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • WildAxe_Counter Less than or equal to 10
        • Then - Actions
          • Set WildAxe_Counter = (WildAxe_Counter + 1)
          • Set WildAxe_Dummy_Loc_1 = (Position of WildAxe_Dummy[1])
          • Set WildAxe_Dummy_Loc_2 = (Position of WildAxe_Dummy[2])
          • Unit - Move WildAxe_Dummy[1] instantly to (WildAxe_Dummy_Loc_1 offset by WildAxe_Interval towards ((WildAxe_Angle + 40.00) - (4.00 x WildAxe_Tilt[1])) degrees)
          • Custom script: set bj_wantDestroyGroup = true
          • Unit Group - Pick every unit in (Units within 88.00 of WildAxe_Dummy_Loc_1 matching ((((Matching unit) is A structure) Equal to False) and ((((Matching unit) belongs to an enemy of (Owner of WildAxe_Caster)) Equal to True) and ((((Matching unit) is alive) Equal to True) and (((Matching unit and do (Actions)
            • Loop - Actions
              • Unit - Cause WildAxe_Caster to damage (Picked unit), dealing (30.00 + (30.00 x (Real((Level of Wild Axe for WildAxe_Caster))))) damage of attack type Chaos and damage type Normal
              • Unit Group - Add (Picked unit) to WildAxe_Group
              • Special Effect - Create a special effect attached to the chest of (Picked unit) using Objects\Spawnmodels\Human\HumanBlood\BloodElfSpellThiefBlood.mdl
              • Special Effect - Destroy (Last created special effect)
          • Destructible - Pick every destructible within 120.00 of WildAxe_Dummy_Loc_1 and do (Actions)
            • Loop - Actions
              • Destructible - Kill (Picked destructible)
          • Custom script: call RemoveLocation (udg_WildAxe_Dummy_Loc_1)
          • Unit - Move WildAxe_Dummy[2] instantly to (WildAxe_Dummy_Loc_2 offset by WildAxe_Interval towards ((WildAxe_Angle - 40.00) + (4.00 x WildAxe_Tilt[1])) degrees)
          • Custom script: set bj_wantDestroyGroup = true
          • Unit Group - Pick every unit in (Units within 88.00 of WildAxe_Dummy_Loc_2 matching ((((Matching unit) is A structure) Equal to False) and ((((Matching unit) belongs to an enemy of (Owner of WildAxe_Caster)) Equal to True) and ((((Matching unit) is alive) Equal to True) and (((Matching unit and do (Actions)
            • Loop - Actions
              • Unit - Cause WildAxe_Caster to damage (Picked unit), dealing (30.00 + (30.00 x (Real((Level of Wild Axe for WildAxe_Caster))))) damage of attack type Chaos and damage type Normal
              • Unit Group - Add (Picked unit) to WildAxe_Group
              • Special Effect - Create a special effect attached to the chest of (Picked unit) using Objects\Spawnmodels\Human\HumanBlood\BloodElfSpellThiefBlood.mdl
          • Destructible - Pick every destructible within 120.00 of WildAxe_Dummy_Loc_2 and do (Actions)
            • Loop - Actions
              • Destructible - Kill (Picked destructible)
          • Custom script: call RemoveLocation (udg_WildAxe_Dummy_Loc_2)
          • Set WildAxe_Tilt[1] = (WildAxe_Tilt[1] + 1.00)
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • WildAxe_Counter Less than or equal to 20
            • Then - Actions
              • Set WildAxe_Counter = (WildAxe_Counter + 1)
              • Set WildAxe_Dummy_Loc_1 = (Position of WildAxe_Dummy[1])
              • Set WildAxe_Dummy_Loc_2 = (Position of WildAxe_Dummy[2])
              • Unit - Move WildAxe_Dummy[1] instantly to (WildAxe_Dummy_Loc_1 offset by WildAxe_Interval towards ((WildAxe_Angle - 40.00) + (4.00 x WildAxe_Tilt2)) degrees)
              • Custom script: set bj_wantDestroyGroup = true
              • Unit Group - Pick every unit in (Units within 88.00 of WildAxe_Dummy_Loc_1 matching ((((Matching unit) is A structure) Equal to False) and ((((Matching unit) belongs to an enemy of (Owner of WildAxe_Caster)) Equal to True) and ((((Matching unit) is alive) Equal to True) and (((Matching unit and do (Actions)
                • Loop - Actions
                  • Unit - Cause WildAxe_Caster to damage (Picked unit), dealing (30.00 + (30.00 x (Real((Level of Wild Axe for WildAxe_Caster))))) damage of attack type Chaos and damage type Normal
                  • Unit Group - Add (Picked unit) to WildAxe_Group
                  • Special Effect - Create a special effect attached to the chest of (Picked unit) using Objects\Spawnmodels\Human\HumanBlood\BloodElfSpellThiefBlood.mdl
                  • Special Effect - Destroy (Last created special effect)
              • Destructible - Pick every destructible within 120.00 of WildAxe_Dummy_Loc_1 and do (Actions)
                • Loop - Actions
                  • Destructible - Kill (Picked destructible)
              • Custom script: call RemoveLocation (udg_WildAxe_Dummy_Loc_1)
              • Unit - Move WildAxe_Dummy[2] instantly to (WildAxe_Dummy_Loc_2 offset by WildAxe_Interval towards ((WildAxe_Angle + 40.00) - (4.00 x WildAxe_Tilt2)) degrees)
              • Custom script: set bj_wantDestroyGroup = true
              • Unit Group - Pick every unit in (Units within 88.00 of WildAxe_Dummy_Loc_2 matching ((((Matching unit) is A structure) Equal to False) and ((((Matching unit) belongs to an enemy of (Owner of WildAxe_Caster)) Equal to True) and ((((Matching unit) is alive) Equal to True) and (((Matching unit and do (Actions)
                • Loop - Actions
                  • Unit - Cause WildAxe_Caster to damage (Picked unit), dealing (30.00 + (30.00 x (Real((Level of Wild Axe for WildAxe_Caster))))) damage of attack type Chaos and damage type Normal
                  • Unit Group - Add (Picked unit) to WildAxe_Group
                  • Special Effect - Create a special effect attached to the chest of (Picked unit) using Objects\Spawnmodels\Human\HumanBlood\BloodElfSpellThiefBlood.mdl
                  • Special Effect - Destroy (Last created special effect)
              • Destructible - Pick every destructible within 120.00 of WildAxe_Dummy_Loc_2 and do (Actions)
                • Loop - Actions
                  • Destructible - Kill (Picked destructible)
              • Custom script: call RemoveLocation (udg_WildAxe_Dummy_Loc_2)
              • Set WildAxe_Tilt2 = (WildAxe_Tilt2 - 1.00)
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • WildAxe_Counter Less than or equal to 30
                • Then - Actions
                  • Custom script: call RemoveLocation (udg_WildAxe_Caster_Loc)
                  • Set WildAxe_Caster_Loc = (Position of WildAxe_Caster)
                  • Set WildAxe_Counter = (WildAxe_Counter + 1)
                  • Set WildAxe_Dummy_Loc_1 = (Position of WildAxe_Dummy[1])
                  • Set WildAxe_Dummy_Loc_2 = (Position of WildAxe_Dummy[2])
                  • Set WildAxe_ReturnDistance_1 = (Distance between WildAxe_Caster_Loc and WildAxe_Dummy_Loc_1)
                  • Set WildAxe_ReturnInterval_1 = (WildAxe_ReturnDistance_1 / 20.00)
                  • Set WildAxe_ReturnDistance_2 = (Distance between WildAxe_Caster_Loc and WildAxe_Dummy_Loc_2)
                  • Set WildAxe_ReturnInterval_2 = (WildAxe_ReturnDistance_2 / 20.00)
                  • Set WildAxe_RetunAngle_1 = ((Angle from WildAxe_Caster_Loc to WildAxe_Dummy_Loc_1) - 180.00)
                  • Set WildAxe_RetunAngle_2 = ((Angle from WildAxe_Caster_Loc to WildAxe_Dummy_Loc_2) - 180.00)
                  • Unit - Move WildAxe_Dummy[1] instantly to (WildAxe_Dummy_Loc_1 offset by WildAxe_ReturnInterval_1 towards ((WildAxe_RetunAngle_1 + 33.00) - (3.00 x WildAxe_Tilt[3])) degrees)
                  • Custom script: set bj_wantDestroyGroup = true
                  • Unit Group - Pick every unit in (Units within 88.00 of WildAxe_Dummy_Loc_1 matching ((((Matching unit) is A structure) Equal to False) and ((((Matching unit) belongs to an enemy of (Owner of WildAxe_Caster)) Equal to True) and ((((Matching unit) is alive) Equal to True) and (((Matching unit and do (Actions)
                    • Loop - Actions
                      • Unit - Cause WildAxe_Caster to damage (Picked unit), dealing (30.00 + (30.00 x (Real((Level of Wild Axe for WildAxe_Caster))))) damage of attack type Chaos and damage type Normal
                      • Unit Group - Add (Picked unit) to WildAxe_ReturnGroup
                      • Special Effect - Create a special effect attached to the chest of (Picked unit) using Objects\Spawnmodels\Human\HumanBlood\BloodElfSpellThiefBlood.mdl
                      • Special Effect - Destroy (Last created special effect)
                  • Destructible - Pick every destructible within 120.00 of WildAxe_Dummy_Loc_1 and do (Actions)
                    • Loop - Actions
                      • Destructible - Kill (Picked destructible)
                  • Custom script: call RemoveLocation (udg_WildAxe_Dummy_Loc_1)
                  • Unit - Move WildAxe_Dummy[2] instantly to (WildAxe_Dummy_Loc_2 offset by WildAxe_ReturnInterval_2 towards ((WildAxe_RetunAngle_2 - 33.00) + (3.00 x WildAxe_Tilt[3])) degrees)
                  • Custom script: set bj_wantDestroyGroup = true
                  • Unit Group - Pick every unit in (Units within 88.00 of WildAxe_Dummy_Loc_2 matching ((((Matching unit) is A structure) Equal to False) and ((((Matching unit) belongs to an enemy of (Owner of WildAxe_Caster)) Equal to True) and ((((Matching unit) is alive) Equal to True) and (((Matching unit and do (Actions)
                    • Loop - Actions
                      • Unit - Cause WildAxe_Caster to damage (Picked unit), dealing (30.00 + (30.00 x (Real((Level of Wild Axe for WildAxe_Caster))))) damage of attack type Chaos and damage type Normal
                      • Unit Group - Add (Picked unit) to WildAxe_ReturnGroup
                      • Special Effect - Create a special effect attached to the chest of (Picked unit) using Objects\Spawnmodels\Human\HumanBlood\BloodElfSpellThiefBlood.mdl
                      • Special Effect - Destroy (Last created special effect)
                  • Destructible - Pick every destructible within 120.00 of WildAxe_Dummy_Loc_2 and do (Actions)
                    • Loop - Actions
                      • Destructible - Kill (Picked destructible)
                  • Custom script: call RemoveLocation (udg_WildAxe_Dummy_Loc_2)
                  • Set WildAxe_Tilt[3] = (WildAxe_Tilt[3] + 1.00)
                • Else - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • WildAxe_Counter Greater than 30
                    • Then - Actions
                      • Custom script: call RemoveLocation (udg_WildAxe_Caster_Loc)
                      • Set WildAxe_Caster_Loc = (Position of WildAxe_Caster)
                      • Set WildAxe_Dummy_Loc_1 = (Position of WildAxe_Dummy[1])
                      • Set WildAxe_Dummy_Loc_2 = (Position of WildAxe_Dummy[2])
                      • Set WildAxe_Check[1] = (Distance between WildAxe_Caster_Loc and WildAxe_Dummy_Loc_1)
                      • Set WildAxe_Check[2] = (Distance between WildAxe_Caster_Loc and WildAxe_Dummy_Loc_2)
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • (WildAxe_Check[1] Greater than 20.00) or (WildAxe_Check[2] Greater than 20.00)
                        • Then - Actions
                          • Set WildAxe_ReturnInterval_1 = 35.00
                          • Set WildAxe_ReturnInterval_2 = 35.00
                          • Set WildAxe_RetunAngle_1 = ((Angle from WildAxe_Caster_Loc to WildAxe_Dummy_Loc_1) - 180.00)
                          • Set WildAxe_RetunAngle_2 = ((Angle from WildAxe_Caster_Loc to WildAxe_Dummy_Loc_2) - 180.00)
                          • Unit - Move WildAxe_Dummy[1] instantly to (WildAxe_Dummy_Loc_1 offset by WildAxe_ReturnInterval_1 towards WildAxe_RetunAngle_1 degrees)
                          • Custom script: set bj_wantDestroyGroup = true
                          • Unit Group - Pick every unit in (Units within 88.00 of WildAxe_Dummy_Loc_1 matching ((((Matching unit) is A structure) Equal to False) and ((((Matching unit) belongs to an enemy of (Owner of WildAxe_Caster)) Equal to True) and ((((Matching unit) is alive) Equal to True) and (((Matching unit and do (Actions)
                            • Loop - Actions
                              • Unit - Cause WildAxe_Caster to damage (Picked unit), dealing (30.00 + (30.00 x (Real((Level of Wild Axe for WildAxe_Caster))))) damage of attack type Chaos and damage type Normal
                              • Unit Group - Add (Picked unit) to WildAxe_ReturnGroup
                              • Special Effect - Create a special effect attached to the chest of (Picked unit) using Objects\Spawnmodels\Human\HumanBlood\BloodElfSpellThiefBlood.mdl
                              • Special Effect - Destroy (Last created special effect)
                          • Destructible - Pick every destructible within 120.00 of WildAxe_Dummy_Loc_1 and do (Actions)
                            • Loop - Actions
                              • Destructible - Kill (Picked destructible)
                          • Custom script: call RemoveLocation (udg_WildAxe_Dummy_Loc_1)
                          • Unit - Move WildAxe_Dummy[2] instantly to (WildAxe_Dummy_Loc_2 offset by WildAxe_ReturnInterval_2 towards WildAxe_RetunAngle_2 degrees)
                          • Custom script: set bj_wantDestroyGroup = true
                          • Unit Group - Pick every unit in (Units within 88.00 of WildAxe_Dummy_Loc_2 matching ((((Matching unit) is A structure) Equal to False) and ((((Matching unit) belongs to an enemy of (Owner of WildAxe_Caster)) Equal to True) and ((((Matching unit) is alive) Equal to True) and (((Matching unit and do (Actions)
                            • Loop - Actions
                              • Unit - Cause WildAxe_Caster to damage (Picked unit), dealing (30.00 + (30.00 x (Real((Level of Wild Axe for WildAxe_Caster))))) damage of attack type Chaos and damage type Normal
                              • Unit Group - Add (Picked unit) to WildAxe_ReturnGroup
                              • Special Effect - Create a special effect attached to the chest of (Picked unit) using Objects\Spawnmodels\Human\HumanBlood\BloodElfSpellThiefBlood.mdl
                              • Special Effect - Destroy (Last created special effect)
                          • Destructible - Pick every destructible within 120.00 of WildAxe_Dummy_Loc_2 and do (Actions)
                            • Loop - Actions
                              • Destructible - Kill (Picked destructible)
                          • Custom script: call RemoveLocation (udg_WildAxe_Dummy_Loc_2)
                        • Else - Actions
                          • Countdown Timer - Pause WildAxe_Timer
                          • Unit - Kill WildAxe_Dummy[1]
                          • Unit - Kill WildAxe_Dummy[2]
                          • Unit - Remove WildAxe_Dummy[1] from the game
                          • Unit - Remove WildAxe_Dummy[2] from the game
                          • Custom script: call RemoveLocation (udg_WildAxe_Dummy_Loc_1)
                          • Custom script: call RemoveLocation (udg_WildAxe_Dummy_Loc_2)
                          • Custom script: call RemoveLocation (udg_WildAxe_Caster_Loc)
                          • Custom script: call RemoveLocation (udg_WildAxe_Target_Loc)
                          • Unit Group - Remove all units from WildAxe_Group
                          • Unit Group - Remove all units from WildAxe_ReturnGroup
                          • Set WildAxe_ReturnDistance_1 = 0.00
                          • Set WildAxe_ReturnDistance_2 = 0.00
                          • Set WildAxe_ReturnInterval_1 = 0.00
                          • Set WildAxe_ReturnInterval_2 = 0.00
                          • Set WildAxe_Distance = 0.00
                          • Set WildAxe_Tilt[1] = 1.00
                          • Set WildAxe_Tilt2 = 10.00
                          • Set WildAxe_Tilt[3] = 1.00
                          • Set WildAxe_Interval = 0.00
                          • Set WildAxe_Counter = 1
                          • Set WildAxe_Angle = 0.00
                          • Set WildAxe_RetunAngle_1 = 0.00
                          • Set WildAxe_RetunAngle_2 = 0.00
                          • Set WildAxe_Check[1] = 0.00
                          • Set WildAxe_Check[2] = 0.00
                    • Else - Actions
Uhm, yeah.
 
Last edited:
Level 3
Joined
Nov 11, 2007
Messages
39
I just ran this through leak check and came up with this:

Please open a text file to analyze
------------------
Selected file is over 100 lines and will not be displayed visually.
Total lines: 260

(Line: 47 ) (Word: 4 ) Special Effect Leak
Special Effect - Create a special effect attached to the chest of (Picked unit) using Objects\Spawnmodels\Human\HumanBlood\BloodElfSpellThiefBlood.mdl
Special Effect - ^Leak
(Suggested fix) Special Effect - Destroy (Last created special effect)

Location variable has not been removed: WildAxe_Dummy_Loc_1
Location variable has not been removed: WildAxe_Dummy_Loc_2
Location variable has not been removed: WildAxe_Dummy_Loc_1
Location variable has not been removed: WildAxe_Dummy_Loc_2
Location variable has not been removed: WildAxe_Caster_Loc
Location variable has not been removed: WildAxe_Dummy_Loc_1
Location variable has not been removed: WildAxe_Dummy_Loc_2
Location variable has not been removed: WildAxe_Caster_Loc
Location variable has not been removed: WildAxe_Dummy_Loc_1
Location variable has not been removed: WildAxe_Dummy_Loc_2

Completed
Total amount of leaks: 1
Leak Rating: Good
------------------
 
Level 4
Joined
Aug 20, 2004
Messages
65
Wait, the trigger already has this:
  • Custom script: call RemoveLocation (udg_WildAxe_Dummy_Loc_1)
  • Custom script: call RemoveLocation (udg_WildAxe_Dummy_Loc_2)
  • Custom script: call RemoveLocation (udg_WildAxe_Caster_Loc)
Wouldn't that work? And the trigger already destroys all special effects the line after they are created, doesn't it?

What about the line: "Pick every destructable within 120 of *dummy unit* Is that a memory leak?
 
Last edited:
Wait, the trigger already has this:
  • Custom script: call RemoveLocation (udg_WildAxe_Dummy_Loc_1)
  • Custom script: call RemoveLocation (udg_WildAxe_Dummy_Loc_2)
  • Custom script: call RemoveLocation (udg_WildAxe_Caster_Loc)
Wouldn't that work? And the trigger already destroys all special effects the line after they are created, doesn't it?

What about the line: "Pick every destructable within 120 of *dummy unit* Is that a memory leak?

Yeah sometimes leakcheck tells you things leak that don't. Usually it's if you make a point variable but destroy it later in the trigger. Just look at the bottom number.

It says that all that leaks is one Special Effect.

That's very good for such a long trigger.

If your map still lags after this has been rectified it must be something else that leaks.
 
Level 4
Joined
Aug 20, 2004
Messages
65
It still lags almost to a stand still after 3 uses of the skill. I fixed the special effect line, too. I'm also targeting an open area with no units to make a special effect on, or destructibles to put into a group. . don't know if that makes a difference or not.

And as I said in my first post, this isn't my skill; it was made by Netherdrake over at thehelper.net.
 
Level 4
Joined
Aug 20, 2004
Messages
65
Well, the skill works perfectly. it damages, destroys trees, makes the special effects. . . and almost freezes my map. I'll try removing the destructible destruction. It's not really essential to the skill anyway.
 
Status
Not open for further replies.
Top