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

Removing a leak

Status
Not open for further replies.
Level 13
Joined
Oct 16, 2010
Messages
737
Hi

I was just wondering whether I need to remove a leak if I pick a unit group that is relevant throughout the whole game?

AKA units will be spawned and put into the group, when they are killed it'll remove them from their group, every so on triggers will pick the group and make any units that are outside of a region move back into the region.
 
Well if you are using GUI, it will create a unit group every time you pick units.

However, if you are adding the unit to the group when you spawn it, it will not cause leaks.

For example:

  • Unit Group - Pick every unit in Playable Map Area Matching (Conditions) and add (Picked Unit) to UnitGroup
In this case it will leak, since you are creating a new unit group to enumerate units, and you would need to add this line above it:

  • Custom Script - call bj_wantDestroyGroup = true

But if you are just adding spawned units to your unit group variable, it should be fine.

Example:

  • Unit Group - Add Triggering Unit to GroupVariable
This will not leak, because you are adding a unit to an already existing unit group, which means the trigger will not create one for you and fail to destroy it.

But yeah, unless you post the trigger, there's no way to know for sure.
 
Level 13
Joined
Oct 16, 2010
Messages
737
Here is one of my spawning triggers.

  • Outskirts L Spawn
    • Events
      • Time - Every 45.00 seconds of game time
    • Conditions
      • (Number of units in OutL_Group) Less than 8
    • Actions
      • Set TempPoint = (Random point in Outskirt Spawn L <gen>)
      • Set TempInt = (Random integer number between 1 and 6)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • TempInt Equal to 1
        • Then - Actions
          • -------- Spawn Weedle, Kakuna, Beedrill --------
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Difficulty Less than or equal to 10
            • Then - Actions
              • Unit - Create 1 Weedle for Player 12 (Brown) at TempPoint facing Default building facing degrees
              • Hero - Set (Last created unit) Hero-level to (Random integer number between 2 and 3), Hide level-up graphics
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Difficulty Less than or equal to 25
                • Then - Actions
                  • Unit - Create 1 Kakuna for Player 12 (Brown) at TempPoint facing Default building facing degrees
                  • Hero - Set (Last created unit) Hero-level to (Random integer number between 6 and 10), Hide level-up graphics
                • Else - Actions
                  • Unit - Create 1 Beedrill for Player 12 (Brown) at TempPoint facing Default building facing degrees
                  • Hero - Set (Last created unit) Hero-level to (Random integer number between 14 and 26), Hide level-up graphics
          • Unit Group - Add (Last created unit) to OutL_Group
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • TempInt Equal to 2
              • Difficulty Greater than or equal to 5
            • Then - Actions
              • -------- Spawn Ekans, Arbok --------
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Difficulty Less than or equal to 18
                • Then - Actions
                  • Unit - Create 1 Ekans for Player 12 (Brown) at TempPoint facing Default building facing degrees
                  • Hero - Set (Last created unit) Hero-level to (Random integer number between 3 and 6), Hide level-up graphics
                • Else - Actions
                  • Unit - Create 1 Arbok for Player 12 (Brown) at TempPoint facing Default building facing degrees
                  • Hero - Set (Last created unit) Hero-level to (Random integer number between 15 and 30), Hide level-up graphics
              • Unit Group - Add (Last created unit) to OutL_Group
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • TempInt Equal to 3
                  • Difficulty Greater than or equal to 5
                • Then - Actions
                  • -------- Spawn Zubat, Golbat --------
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • Difficulty Less than or equal to 18
                    • Then - Actions
                      • Unit - Create 1 Zubat for Player 12 (Brown) at TempPoint facing Default building facing degrees
                      • Hero - Set (Last created unit) Hero-level to (Random integer number between 3 and 6), Hide level-up graphics
                    • Else - Actions
                      • Unit - Create 1 Golbat for Player 12 (Brown) at TempPoint facing Default building facing degrees
                      • Hero - Set (Last created unit) Hero-level to (Random integer number between 15 and 30), Hide level-up graphics
                  • Unit Group - Add (Last created unit) to OutL_Group
                • Else - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • TempInt Equal to 4
                      • Difficulty Greater than or equal to 8
                    • Then - Actions
                      • -------- Spawn Koffing, Weezing --------
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • Difficulty Less than or equal to 25
                        • Then - Actions
                          • Unit - Create 1 Koffing for Player 12 (Brown) at TempPoint facing Default building facing degrees
                          • Hero - Set (Last created unit) Hero-level to (Random integer number between 4 and 8), Hide level-up graphics
                        • Else - Actions
                          • Unit - Create 1 Weezing for Player 12 (Brown) at TempPoint facing Default building facing degrees
                          • Hero - Set (Last created unit) Hero-level to (Random integer number between 18 and 36), Hide level-up graphics
                      • Unit Group - Add (Last created unit) to OutL_Group
                    • Else - Actions
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • TempInt Equal to 5
                          • Difficulty Greater than or equal to 12
                        • Then - Actions
                          • -------- Spawn Abra, Kadabra, Alakazam --------
                          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            • If - Conditions
                              • Difficulty Less than or equal to 16
                            • Then - Actions
                              • Unit - Create 1 Abra for Player 12 (Brown) at TempPoint facing Default building facing degrees
                              • Hero - Set (Last created unit) Hero-level to (Random integer number between 5 and 10), Hide level-up graphics
                            • Else - Actions
                              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                • If - Conditions
                                  • Difficulty Less than or equal to 32
                                • Then - Actions
                                  • Unit - Create 1 Kadabra for Player 12 (Brown) at TempPoint facing Default building facing degrees
                                  • Hero - Set (Last created unit) Hero-level to (Random integer number between 15 and 25), Hide level-up graphics
                                • Else - Actions
                                  • Unit - Create 1 Alakazam for Player 12 (Brown) at TempPoint facing Default building facing degrees
                                  • Hero - Set (Last created unit) Hero-level to (Random integer number between 24 and 45), Hide level-up graphics
                          • Unit Group - Add (Last created unit) to OutL_Group
                        • Else - Actions
                          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            • If - Conditions
                              • TempInt Equal to 6
                              • Difficulty Greater than or equal to 12
                            • Then - Actions
                              • -------- Spawn Gastly, Haunter, Gengar --------
                              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                • If - Conditions
                                  • Difficulty Less than or equal to 16
                                • Then - Actions
                                  • Unit - Create 1 Gastly for Player 12 (Brown) at TempPoint facing Default building facing degrees
                                  • Hero - Set (Last created unit) Hero-level to (Random integer number between 5 and 10), Hide level-up graphics
                                • Else - Actions
                                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                    • If - Conditions
                                      • Difficulty Less than or equal to 32
                                    • Then - Actions
                                      • Unit - Create 1 Haunter for Player 12 (Brown) at TempPoint facing Default building facing degrees
                                      • Hero - Set (Last created unit) Hero-level to (Random integer number between 15 and 25), Hide level-up graphics
                                    • Else - Actions
                                      • Unit - Create 1 Gengar for Player 12 (Brown) at TempPoint facing Default building facing degrees
                                      • Hero - Set (Last created unit) Hero-level to (Random integer number between 24 and 45), Hide level-up graphics
                              • Unit Group - Add (Last created unit) to OutL_Group
                            • Else - Actions
                              • Trigger - Run (This trigger) (checking conditions)
      • Custom script: call RemoveLocation(udg_TempPoint)
Here is part of my "unit is killed" trigger. This is just the part that removes units from groups

  • Remove from Group
    • Events
    • Conditions
    • Actions
      • Set TempUnit = (Dying unit)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (TempUnit is in CornerBL_Group) Equal to True
        • Then - Actions
          • Unit Group - Remove TempUnit from CornerBL_Group
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (TempUnit is in CornerBR_Group) Equal to True
            • Then - Actions
              • Unit Group - Remove TempUnit from CornerBR_Group
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (TempUnit is in CornerTL_Group) Equal to True
                • Then - Actions
                  • Unit Group - Remove TempUnit from CornerTL_Group
                • Else - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (TempUnit is in CornerTR_Group) Equal to True
                    • Then - Actions
                      • Unit Group - Remove TempUnit from CornerTR_Group
                    • Else - Actions
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • (TempUnit is in MidB_Group) Equal to True
                        • Then - Actions
                          • Unit Group - Remove TempUnit from MidB_Group
                        • Else - Actions
                          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            • If - Conditions
                              • (TempUnit is in MidL_Group) Equal to True
                            • Then - Actions
                              • Unit Group - Remove TempUnit from MidL_Group
                            • Else - Actions
                              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                • If - Conditions
                                  • (TempUnit is in MidR_Group) Equal to True
                                • Then - Actions
                                  • Unit Group - Remove TempUnit from MidR_Group
                                • Else - Actions
                                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                    • If - Conditions
                                      • (TempUnit is in MidT_Group) Equal to True
                                    • Then - Actions
                                      • Unit Group - Remove TempUnit from MidT_Group
                                    • Else - Actions
                                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                        • If - Conditions
                                          • (TempUnit is in Middle_Group) Equal to True
                                        • Then - Actions
                                          • Unit Group - Remove TempUnit from Middle_Group
                                        • Else - Actions
                                          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                            • If - Conditions
                                              • (TempUnit is in OutB_Group) Equal to True
                                            • Then - Actions
                                              • Unit Group - Remove TempUnit from OutB_Group
                                            • Else - Actions
                                              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                                • If - Conditions
                                                  • (TempUnit is in OutL_Group) Equal to True
                                                • Then - Actions
                                                  • Unit Group - Remove TempUnit from OutL_Group
                                                • Else - Actions
                                                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                                    • If - Conditions
                                                      • (TempUnit is in OutR_Group) Equal to True
                                                    • Then - Actions
                                                      • Unit Group - Remove TempUnit from OutR_Group
                                                    • Else - Actions
                                                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                                        • If - Conditions
                                                          • (TempUnit is in OutT_Group) Equal to True
                                                        • Then - Actions
                                                          • Unit Group - Remove TempUnit from OutT_Group
                                                        • Else - Actions
Here is my movement trigger (the one in question)

  • Move Outskirts PKMN
    • Events
      • Time - Every 20.00 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in OutL_Group and do (Actions)
        • Loop - Actions
          • Set TempUnit = (Picked unit)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Outskirt Boundry L <gen> contains TempUnit) Equal to False
            • Then - Actions
              • Set TempPoint = (Random point in Outskirt Boundry L <gen>)
              • Unit - Order TempUnit to Move To TempPoint
              • Custom script: call RemoveLocation(udg_TempPoint)
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Random integer number between 1 and 10) Equal to 1
                • Then - Actions
                  • Set TempPoint = (Random point in Outskirt Boundry L <gen>)
                  • Unit - Order TempUnit to Attack-Move To TempPoint
                  • Custom script: call RemoveLocation(udg_TempPoint)
                • Else - Actions
 
Level 28
Joined
Sep 26, 2009
Messages
2,520
Memory leak is when you lose all reference to some object.
All objects take a tiny bit of piece of your memory space - if you lose all reference to that object, you have no way to remove it, hence it will remain in the memory as long as you run WCIII and it will take that memory space for no reason - thus it's a memory leak.

As long as you don't lose all reference, it won't become memory leak.
 
Status
Not open for further replies.
Top