Memory Leaks in these triggers?

chukky-jr

Member
Reaction score
15
okay just a quick question, does these trigger leaks? (might ask a few more)

Trigger:
  • RedAICampfire
    • Events
      • Unit - A unit Is issued an order with no target
    • Conditions
      • (Player 1 (Red) controller) Equal to Computer
      • (Player 1 (Red) Current lumber) Greater than or equal to 5
      • (Number of living Tent units owned by Player 1 (Red)) Equal to 1
      • (Number of living Campfire units owned by Player 1 (Red)) Equal to 0
      • (Number of living BonFire units owned by Player 1 (Red)) Equal to 0
      • (Current order of Survivor 0003 <gen>) Equal to (Order(harvest))
    • Actions
      • Floating Text - Create floating text that reads |cffF00202Survivor|... above Survivor 0003 <gen> with Z offset 0.00, using font size 10.00, color (100.00%, 100.00%, 100.00%), and 0.00% transparency
      • Set Text = (Last created floating text)
      • Floating Text - Change Text: Disable permanence
      • Floating Text - Set the velocity of Text to 30.00 towards 90.00 degrees
      • Floating Text - Change the fading age of Text to 1.50 seconds
      • Floating Text - Change the lifespan of Text to 3.00 seconds
      • Custom script: set udg_Text=null
      • Set RedBaseBuilding = (RedBase offset by (Random real number between 200.00 and 300.00) towards (Random angle) degrees)
      • Unit - Order Survivor 0018 <gen> to build a Campfire at RedBaseBuilding
      • Custom script: call RemoveLocation(udg_RedBaseBuilding)


Trigger:
  • RedAITurretUpgrade
    • Events
      • Player - Player 1 (Red)'s Current lumber becomes Greater than or equal to 15.00
      • Player - Player 1 (Red)'s Current gold becomes Greater than or equal to 15.00
    • Conditions
      • (Player 1 (Red) controller) Equal to Computer
      • (Number of living Turret Base units owned by Player 1 (Red)) Greater than or equal to 1
    • Actions
      • Set AIUnitGroup = (Units owned by Player 1 (Red) of type Turret Base)
      • Unit Group - Pick every unit in AIUnitGroup and do (Unit - Order (Picked unit) to train/upgrade to a Gun Tower)
      • Custom script: call DestroyGroup(udg_AIUnitGroup)
      • Custom script: set udg_AIUnitGroup=null


Trigger:
  • Machine Gun B Unit
    • Events
      • Unit - A unit Is attacked
    • Conditions
      • Or - Any (Conditions) are true
        • Conditions
          • (Unit-type of (Attacking unit)) Equal to Sentry Gun
          • (Unit-type of (Attacking unit)) Equal to Sentry Gun II
    • Actions
      • Special Effect - Create a special effect attached to the origin of (Attacked unit) using Abilities\Weapons\GyroCopter\GyroCopterImpact.mdl
      • Wait 2.00 seconds
      • Special Effect - Destroy (Last created special effect)
      • Sound - Attach GyrocopterYesAttack2 <gen> to (Attacking unit)
      • Sound - Set position of GyrocopterYesAttack2 <gen> to (Position of (Attacked unit)) with Z offset 0.00
      • Sound - Play GyrocopterYesAttack2 <gen>
 
I don't think that "Custom script: set udg_AIUnitGroup=null" is necessary after all you already destroyed the group.

"Wait 2.00 seconds" waits always cause problems, i don't know if this case does

I heard that some Floating Text leak if not removed properly, i dont know if the method you used is the correct one since you're not using locals. You might want to dig into that
 
1) it's an excessive line from previous trigger, okay i might delete it

2) then is there any wait command that is almost have no problem?

3) well i did some research that even if floating text does leaks, the max number allowed in game is 100, which means it almost auto-clean itself even if it leaks (i'm pretty sure this one does not leak though)

so overall the only problem is the wait line isn't it?
 
using timers or integers.

i get the timer part (though not sure if i really get it), but how do you use integers as timer?

btw i don't want to be an ass, but does these triggers have leaks?

Trigger:
  • Machine Gun A Unit
    • Events
      • Unit - A unit Is attacked
    • Conditions
      • (Unit-type of (Attacking unit)) Equal to Gun Tower
    • Actions
      • Sound - Attach GyrocopterImpactHit1 <gen> to (Attacking unit)
      • Sound - Attach GyrocopterImpactHit2 <gen> to (Attacking unit)
      • Set RandomPoint = (Position of (Attacked unit))
      • Sound - Set position of GyrocopterImpactHit1 <gen> to RandomPoint with Z offset 0.00
      • Sound - Set position of GyrocopterImpactHit2 <gen> to RandomPoint with Z offset 0.00
      • Custom script: call RemoveLocation(udg_RandomPoint)
      • Set MachineGunSound[(Player number of (Owner of (Attacking unit)))] = (Random integer number between 1 and 2)
      • Wait 0.01 game-time seconds
      • If (MachineGunSound[(Player number of (Owner of (Attacking unit)))] Equal to 1) then do (Sound - Play GyrocopterImpactHit1 <gen>) else do (Sound - Play GyrocopterImpactHit2 <gen>)


Trigger:
  • Machine Gun B Unit
    • Events
      • Unit - A unit Is attacked
    • Conditions
      • Or - Any (Conditions) are true
        • Conditions
          • (Unit-type of (Attacking unit)) Equal to Sentry Gun
          • (Unit-type of (Attacking unit)) Equal to Sentry Gun II
    • Actions
      • Special Effect - Create a special effect attached to the origin of (Attacked unit) using Abilities\Weapons\GyroCopter\GyroCopterImpact.mdl
      • Wait 2.00 seconds
      • Special Effect - Destroy (Last created special effect)
      • Sound - Attach GyrocopterYesAttack2 <gen> to (Attacking unit)
      • Set RandomPoint = (Position of (Attacked unit))
      • Sound - Set position of GyrocopterYesAttack2 <gen> to RandomPoint with Z offset 0.00
      • Custom script: call RemoveLocation(udg_RandomPoint)
      • Sound - Play GyrocopterYesAttack2 <gen>


i don't know whether the Z offset part have leaks or not... tried searching it w/o result...
 
but how do you use integers as timer?
Trigger:
  • Time - Every 1 second of game time
    • Actions
    • Set integer = integer +1
Trigger:
  • Events - ??
    • // if less don't do anything
    • If integer less or equal to "2" then
      • //nothing, or another action if you need
    • elf
    • // if greater do the action you want "remember to set integer to 0"
    • If integer greater or equal to "2" then
      • destroy whatever
      • set integer = 0
    • elf
 
thx but what about these? does it have leaks?

Trigger:
  • Machine Gun A Unit
    • Events
      • Unit - A unit Is attacked
    • Conditions
      • (Unit-type of (Attacking unit)) Equal to Gun Tower
    • Actions
      • Sound - Attach GyrocopterImpactHit1 <gen> to (Attacking unit)
      • Sound - Attach GyrocopterImpactHit2 <gen> to (Attacking unit)
      • Set RandomPoint = (Position of (Attacked unit))
      • Sound - Set position of GyrocopterImpactHit1 <gen> to RandomPoint with Z offset 0.00
      • Sound - Set position of GyrocopterImpactHit2 <gen> to RandomPoint with Z offset 0.00
      • Custom script: call RemoveLocation(udg_RandomPoint)
      • Set MachineGunSound[(Player number of (Owner of (Attacking unit)))] = (Random integer number between 1 and 2)
      • Wait 0.01 game-time seconds
      • If (MachineGunSound[(Player number of (Owner of (Attacking unit)))] Equal to 1) then do (Sound - Play GyrocopterImpactHit1 <gen>) else do (Sound - Play GyrocopterImpactHit2 <gen>)


Trigger:
  • Machine Gun B Unit
    • Events
      • Unit - A unit Is attacked
    • Conditions
      • Or - Any (Conditions) are true
        • Conditions
          • (Unit-type of (Attacking unit)) Equal to Sentry Gun
          • (Unit-type of (Attacking unit)) Equal to Sentry Gun II
    • Actions
      • Special Effect - Create a special effect attached to the origin of (Attacked unit) using Abilities\Weapons\GyroCopter\GyroCopterImpact.mdl
      • Wait 2.00 seconds
      • Special Effect - Destroy (Last created special effect)
      • Sound - Attach GyrocopterYesAttack2 <gen> to (Attacking unit)
      • Set RandomPoint = (Position of (Attacked unit))
      • Sound - Set position of GyrocopterYesAttack2 <gen> to RandomPoint with Z offset 0.00
      • Custom script: call RemoveLocation(udg_RandomPoint)
      • Sound - Play GyrocopterYesAttack2 <gen>


i don't know whether the Z offset part have leaks or not... tried searching it w/o result...
 
as far as i can see no, they don't leak. for future consult read this >tutorial<

i basically have read almost every memory leaks tutorial (including that one), but since i can't find the ones regarding sounds, i ask it here. but thx anyway :)
 
Basically the only leaks you should worry about are Unit Groups and Points. Those are the big ones. Cleaning those up, you shouldn't worry much about any others.
 
Trigger:
  • Machine Gun B Unit
    • Special Effect - Create a special effect attached to the origin of (Attacked unit) using Abilities\Weapons\GyroCopter\GyroCopterImpact.mdl
    • Wait 2.00 seconds
    • Special Effect - Destroy (Last created special effect)


just a question, doesnt "Last created special effect" leak, because it can be overid by another special effect made in another trigger or instance?
I could be wrong though, not entirely sure.
 
It does if another special effect is created during the wait duration. That would change the Special Effect that it refers to, making the most recent one "Last Created". The same concept for other "Last Created" references.
 
i've fixed that one, i set the last created special effect as variable immediately after its creation

btw if my WC3 memory usage keeps going up when i play the map, does that mean memory leaks occur at the map? it increases at a random rate between 20-200 kb memory per second
 
i don't want to be an ass and kick this up, but i gotta to ask since a Leak Checker says my trigger leaks

Code:
Variables
TempGroup : (Line: 9) Location - Removed: No
RandomMovePoint : (Line: 10) Location - Removed: Yes

Code:
Dinosaur Attacks1
    Events
        Time - Every 20.00 seconds of game time
    Conditions
    Actions
        Set PlayerGroup = (All enemies of Player 1 (Red))
        Set PlayerGroup2 = (All allies of Player 1 (Red))
        Set TempReg = (Playable map area)
        Set TempGroup = (Random 1 units from (Units in TempReg owned by (Random player from PlayerGroup)))
        Set RandomMovePoint = (Position of (Random unit from (Units in TempReg owned by (Random player from PlayerGroup2))))
        Unit Group - Pick every unit in TempGroup and do (Unit - Order (Picked unit) to Attack-Move To RandomMovePoint)
        Custom script:   call RemoveRect(udg_TempReg)
        Custom script:   call DestroyGroup(udg_TempGroup)
        Custom script:   call RemoveLocation(udg_RandomMovePoint)
        Custom script:   call DestroyForce(udg_PlayerGroup)
        Custom script:   call DestroyForce(udg_PlayerGroup2)

Trigger:
  • Dinosaur Attacks1
    • Events
      • Time - Every 20.00 seconds of game time
    • Conditions
    • Actions
      • Set PlayerGroup = (All enemies of Player 1 (Red))
      • Set PlayerGroup2 = (All allies of Player 1 (Red))
      • Set TempReg = (Playable map area)
      • Set TempGroup = (Random 1 units from (Units in TempReg owned by (Random player from PlayerGroup)))
      • Set RandomMovePoint = (Position of (Random unit from (Units in TempReg owned by (Random player from PlayerGroup2))))
      • Unit Group - Pick every unit in TempGroup and do (Unit - Order (Picked unit) to Attack-Move To RandomMovePoint)
      • Custom script: call RemoveRect(udg_TempReg)
      • Custom script: call DestroyGroup(udg_TempGroup)
      • Custom script: call RemoveLocation(udg_RandomMovePoint)
      • Custom script: call DestroyForce(udg_PlayerGroup)
      • Custom script: call DestroyForce(udg_PlayerGroup2)


what i dont get this why it said Location not removed? is it becaused units in playable map area leaks? a simple yes it leaks / no it doesn't is very appreciated
 
General chit-chat
Help Users
  • The Helper The Helper:
    News portal has been retired. Main page of site goes to Headline News forum now
  • The Helper The Helper:
    I am working on getting access to the old news portal under a different URL for those that would rather use that for news before we get a different news view.
  • Ghan Ghan:
    Easily done
    +1
  • The Helper The Helper:
    https://www.thehelper.net/pages/news/ is a link to the old news portal - i will integrate it into the interface somewhere when i figure it out
  • Ghan Ghan:
    Need to try something
  • Ghan Ghan:
    Hopefully this won't cause problems.
  • Ghan Ghan:
    Hmm
  • Ghan Ghan:
    I have converted the Headline News forum to an Article type forum. It will now show the top 20 threads with more detail of each thread.
  • Ghan Ghan:
    See how we like that.
  • The Helper The Helper:
    I do not see a way to go past the 1st page of posts on the forum though
  • The Helper The Helper:
    It is OK though for the main page to open up on the forum in the view it was before. As long as the portal has its own URL so it can be viewed that way I do want to try it as a regular forum view for a while
  • Ghan Ghan:
    Yeah I'm not sure what the deal is with the pagination.
  • Ghan Ghan:
    It SHOULD be there so I think it might just be an artifact of having an older style.
  • Ghan Ghan:
    I switched it to a "Standard" article forum. This will show the thread list like normal, but the threads themselves will have the first post set up above the rest of the "comments"
  • The Helper The Helper:
    I don't really get that article forum but I think it is because I have never really seen it used on a multi post thread
  • Ghan Ghan:
    RpNation makes more use of it right now as an example: https://www.rpnation.com/news/
  • The Helper The Helper:
  • The Helper The Helper:
    What do you think Tom?
  • tom_mai78101 tom_mai78101:
    I will have to get used to this.
  • tom_mai78101 tom_mai78101:
    The latest news feed looks good
  • The Helper The Helper:
    I would like to see it again like Ghan had it the first time with pagination though - without the pagination that view will not work but with pagination it just might...
  • The Helper The Helper:
    This drink recipe I have had more than a few times back in the day! Mind Eraser https://www.thehelper.net/threads/cocktail-mind-eraser.194720/

      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