memory leak check

vonahs

New Member
Reaction score
0
would any one mine checking for leaks? i think i did it properly

Trigger:
  • create
    • Events
      • Time - Every 2.00 seconds of game time
    • Conditions
    • Actions
      • -------- Team 1 --------
      • -------- Red/Purple --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Or - Any (Conditions) are true
            • Conditions
              • (Player 1 (Red) slot status) Equal to Is playing
              • (Player 1 (Red) controller) Equal to Computer
        • Then - Actions
          • Set TempPointunit[1] = (Player 4 (Purple) start location)
          • Unit - Create 1 Toy Soldier for Player 4 (Purple) at TempPointunit[1] facing Default building facing degrees
          • Unit - Order (Last created unit) to Attack-Move To (Center of Top Target <gen>)
          • Custom script: call RemoveLocation (udg_TempPointunit[1])
        • Else - Actions
          • Do nothing
      • -------- Blue/Yellow --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Or - Any (Conditions) are true
            • Conditions
              • (Player 2 (Blue) slot status) Equal to Is playing
              • (Player 2 (Blue) controller) Equal to Computer
        • Then - Actions
          • Set TempPointunit[2] = (Player 5 (Yellow) start location)
          • Unit - Create 1 Toy Soldier for Player 5 (Yellow) at TempPointunit[2] facing Default building facing degrees
          • Unit - Order (Last created unit) to Attack-Move To (Center of Top Target <gen>)
          • Custom script: call RemoveLocation (udg_TempPointunit[2])
        • Else - Actions
          • Do nothing
      • -------- Teal/Orange --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Or - Any (Conditions) are true
            • Conditions
              • (Player 3 (Teal) slot status) Equal to Is playing
              • (Player 3 (Teal) controller) Equal to Computer
        • Then - Actions
          • Set TempPointunit[3] = (Player 6 (Orange) start location)
          • Unit - Create 1 Toy Soldier for Player 6 (Orange) at TempPointunit[3] facing Default building facing degrees
          • Unit - Order (Last created unit) to Attack-Move To (Center of Top Target <gen>)
          • Custom script: call RemoveLocation (udg_TempPointunit[3])
        • Else - Actions
          • Do nothing
      • -------- Team 2 --------
      • -------- Green/Light Blue --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Or - Any (Conditions) are true
            • Conditions
              • (Player 7 (Green) slot status) Equal to Is playing
              • (Player 7 (Green) controller) Equal to Computer
        • Then - Actions
          • Set TempPointunit[4] = (Player 10 (Light Blue) start location)
          • Unit - Create 1 Toy Soldier for Player 10 (Light Blue) at TempPointunit[4] facing Default building facing degrees
          • Unit - Order (Last created unit) to Attack-Move To (Center of Bottom Target <gen>)
          • Custom script: call RemoveLocation (udg_TempPointunit[4])
        • Else - Actions
          • Do nothing
      • -------- Pink/Dark Green --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Or - Any (Conditions) are true
            • Conditions
              • (Player 8 (Pink) slot status) Equal to Is playing
              • (Player 8 (Pink) controller) Equal to Computer
        • Then - Actions
          • Set TempPointunit[5] = (Player 11 (Dark Green) start location)
          • Unit - Create 1 Toy Soldier for Player 11 (Dark Green) at TempPointunit[5] facing Default building facing degrees
          • Unit - Order (Last created unit) to Attack-Move To (Center of Bottom Target <gen>)
          • Custom script: call RemoveLocation (udg_TempPointunit[5])
        • Else - Actions
          • Do nothing
      • -------- Gray/ Brown --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Or - Any (Conditions) are true
            • Conditions
              • (Player 9 (Gray) slot status) Equal to Is playing
              • (Player 9 (Gray) controller) Equal to Computer
        • Then - Actions
          • Set TempPointunit[6] = (Player 12 (Brown) start location)
          • Unit - Create 1 Toy Soldier for Player 12 (Brown) at TempPointunit[6] facing Default building facing degrees
          • Unit - Order (Last created unit) to Attack-Move To (Center of Bottom Target <gen>)
          • Custom script: call RemoveLocation (udg_TempPointunit[6])
        • Else - Actions
          • Do nothing
 

Accname

2D-Graphics enthusiast
Reaction score
1,464
you are leaking several locations, each time you call this:
Code:
(Center of Top Target <gen>)
or similar code you are leaking memory.
you need another point variable for this.
 

vonahs

New Member
Reaction score
0
so another set newvar = (Center of Top Target <gen>)?

is the rest good?

here is the new version.
Trigger:
  • create
    • Events
      • Time - Every 2.00 seconds of game time
    • Conditions
    • Actions
      • Set TempPointattack[1] = (Center of Top Target &lt;gen&gt;)
      • Set TempPointattack[2] = (Center of Bottom Target &lt;gen&gt;)
      • -------- Team 1 --------
      • -------- Red/Purple --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Or - Any (Conditions) are true
            • Conditions
              • (Player 1 (Red) slot status) Equal to Is playing
              • (Player 1 (Red) controller) Equal to Computer
        • Then - Actions
          • Set TempPointunit[1] = (Player 4 (Purple) start location)
          • Unit - Create 1 Toy Soldier for Player 4 (Purple) at TempPointunit[1] facing Default building facing degrees
          • Unit - Order (Last created unit) to Attack-Move To TempPointattack[1]
          • Custom script: call RemoveLocation (udg_TempPointunit[1])
        • Else - Actions
          • Do nothing
      • -------- Blue/Yellow --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Or - Any (Conditions) are true
            • Conditions
              • (Player 2 (Blue) slot status) Equal to Is playing
              • (Player 2 (Blue) controller) Equal to Computer
        • Then - Actions
          • Set TempPointunit[2] = (Player 5 (Yellow) start location)
          • Unit - Create 1 Toy Soldier for Player 5 (Yellow) at TempPointunit[2] facing Default building facing degrees
          • Unit - Order (Last created unit) to Attack-Move To TempPointattack[1]
          • Custom script: call RemoveLocation (udg_TempPointunit[2])
        • Else - Actions
          • Do nothing
      • -------- Teal/Orange --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Or - Any (Conditions) are true
            • Conditions
              • (Player 3 (Teal) slot status) Equal to Is playing
              • (Player 3 (Teal) controller) Equal to Computer
        • Then - Actions
          • Set TempPointunit[3] = (Player 6 (Orange) start location)
          • Unit - Create 1 Toy Soldier for Player 6 (Orange) at TempPointunit[3] facing Default building facing degrees
          • Unit - Order (Last created unit) to Attack-Move To TempPointattack[1]
          • Custom script: call RemoveLocation (udg_TempPointunit[3])
        • Else - Actions
          • Do nothing
      • -------- Team 2 --------
      • -------- Green/Light Blue --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Or - Any (Conditions) are true
            • Conditions
              • (Player 7 (Green) slot status) Equal to Is playing
              • (Player 7 (Green) controller) Equal to Computer
        • Then - Actions
          • Set TempPointunit[4] = (Player 10 (Light Blue) start location)
          • Unit - Create 1 Toy Soldier for Player 10 (Light Blue) at TempPointunit[4] facing Default building facing degrees
          • Unit - Order (Last created unit) to Attack-Move To TempPointattack[2]
          • Custom script: call RemoveLocation (udg_TempPointunit[4])
        • Else - Actions
          • Do nothing
      • -------- Pink/Dark Green --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Or - Any (Conditions) are true
            • Conditions
              • (Player 8 (Pink) slot status) Equal to Is playing
              • (Player 8 (Pink) controller) Equal to Computer
        • Then - Actions
          • Set TempPointunit[5] = (Player 11 (Dark Green) start location)
          • Unit - Create 1 Toy Soldier for Player 11 (Dark Green) at TempPointunit[5] facing Default building facing degrees
          • Unit - Order (Last created unit) to Attack-Move To TempPointattack[2]
          • Custom script: call RemoveLocation (udg_TempPointunit[5])
        • Else - Actions
          • Do nothing
      • -------- Gray/ Brown --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Or - Any (Conditions) are true
            • Conditions
              • (Player 9 (Gray) slot status) Equal to Is playing
              • (Player 9 (Gray) controller) Equal to Computer
        • Then - Actions
          • Set TempPointunit[6] = (Player 12 (Brown) start location)
          • Unit - Create 1 Toy Soldier for Player 12 (Brown) at TempPointunit[6] facing Default building facing degrees
          • Unit - Order (Last created unit) to Attack-Move To TempPointattack[2]
          • Custom script: call RemoveLocation (udg_TempPointunit[6])
        • Else - Actions
          • Do nothing
      • Custom script: call RemoveLocation (udg_TempPointattack[1])
      • Custom script: call RemoveLocation (udg_TempPointattack[2])
 

Azlier

Old World Ghost
Reaction score
461
If you're going to set and unset some variables to the same values every two seconds, why not just make the variables always contain the value thus requiring no cleanup?

But for an answer to the original question, yes. It looks as leakless as GUI can be to me.
 

skyblader

You're living only because it's illegal killing.
Reaction score
159
Not sure if you want this, but you could shorten your code by a lot using loops.

An example (Hand written)
Trigger:
  • -------- Red/Purple --------
    • For Loop Integer A from 1 to 3 do
      • Loop
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • Or - Any (Conditions) are true
              • Conditions
                • (Player (For loop integer A) slot status) Equal to Is playing
                • (Player (For loop integer A) controller) Equal to Computer
        • Then - Actions
          • Set TempPointunit[For loop integer A] = (Player (For loop integer A + 3) start location)
          • Unit - Create 1 Toy Soldier for Player (For loop integer A + 3) at TempPointunit[For loop integer A] facing Default building facing degrees
          • Unit - Order (Last created unit) to Attack-Move To TempPointattack[1]
          • Custom script: call RemoveLocation (udg_TempPointunit[For loop integerA])
        • Else - Actions
          • Do nothing
 

Ayanami

칼리
Reaction score
288
Seems to be okay, though you could use a loop to shorten your code, like stated above. Also, you can get rid of the "Do nothing" actions, as they...do nothing indeed.
 

vonahs

New Member
Reaction score
0
how does that shorten the code? surry im still new and i have made a good progress but still dont understand all of it.

is that last code written effect all 3 players (red blue and teal) or just red? cuz if it is red then it seems longer than what i wrote.

btw i just learned memory leaks last week, so thats why id like people to check them, cuz im stil not sure.
 

skyblader

You're living only because it's illegal killing.
Reaction score
159
When you use the action for loop integer A from 1 to 3, it means repeat the actions three times. Now the numbers inside the loop are different, so you'll have to make it work with the integer A.

So the first time it runs, integer A = 1.

So for player 1, you'll do Player[integer A]
For player 4, you'll do Player [integer A + 3]
And if it's constant, you just put 1 as 1.

So this works even if it's run the second time. Which means integer A = 2.

Player [integer A] would be player 2,
Player [integer A + 3] would be player 5,
and the constant should be 1
So it's actually running 3 times, shortening the length of the code but not the action.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top