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>
 

Dirac

22710180
Reaction score
147
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
 

chukky-jr

Member
Reaction score
15
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?
 

chukky-jr

Member
Reaction score
15
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...
 

rexpim

Member
Reaction score
8
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
 

chukky-jr

Member
Reaction score
15
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...
 

chukky-jr

Member
Reaction score
15
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 :)
 

tommerbob

Minecraft. :D
Reaction score
110
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.
 

Inflicted

Currently inactive
Reaction score
63
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.
 

KaerfNomekop

Swim, fishies. Swim through the veil of steel.
Reaction score
613
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.
 

chukky-jr

Member
Reaction score
15
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
 

chukky-jr

Member
Reaction score
15
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
  • No one is chatting at the moment.

      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