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,463
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.
  • WildTurkey WildTurkey:
    is there a stephen green in the house?
    +1
  • The Helper The Helper:
    What is up WildTurkey?
  • The Helper The Helper:
    Looks like Google fixed whatever mistake that made the recipes on the site go crazy and we are no longer trending towards a recipe site lol - I don't care though because it motivated me to spend alot of time on the site improving it and at least now the content people are looking at is not stupid and embarrassing like it was when I first got back into this like 5 years ago.
  • The Helper The Helper:
    Plus - I have a pretty bad ass recipe collection now! That section of the site is 10 thousand times better than it was before
  • The Helper The Helper:
    We now have a web designer at my job. A legit talented professional! I am going to get him to redesign the site theme. It is time.
  • Varine Varine:
    I got one more day of community service and then I'm free from this nonsense! I polished a cop car today for a funeral or something I guess
  • Varine Varine:
    They also were digging threw old shit at the sheriff's office and I tried to get them to give me the old electronic stuff, but they said no. They can't give it to people because they might use it to impersonate a cop or break into their network or some shit? idk but it was a shame to see them take a whole bunch of radios and shit to get shredded and landfilled
  • The Helper The Helper:
    whatever at least you are free
  • Monovertex Monovertex:
    How are you all? :D
    +1
  • Ghan Ghan:
    Howdy
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top