• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Leaking like a m'fer

Status
Not open for further replies.
Hey I am asking for help with a topic that I thought was pretty straightforward, and that I thought I knew pretty well, but apparently I don't....

This trigger is leaking like hell and I don't know where/how/why, as I am removing all points before they are overwritten. After a minute or more of having this active it takes a shit ton of time to exit the game.

  • Move Wards
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • Set TempLocation[1] = (Position of Ward[1])
      • Unit - Move Ward[1] instantly to TempLocation[1], facing ((Facing of Ward[1]) + 1.00) degrees
      • Custom script: call RemoveLocation (udg_TempLocation[1])
      • -------- ---- --------
      • -------- Start Beam 1 --------
      • -------- ---- --------
      • Set TempLocation[1] = (Position of Ward[1])
      • Set TempLocation[2] = (TempLocation[1] offset by 100.00 towards (Facing of Ward[1]) degrees)
      • Unit - Move Ward[2] instantly to TempLocation[2], facing (Facing of Ward[2]) degrees
      • Custom script: call RemoveLocation (udg_TempLocation[1])
      • Custom script: call RemoveLocation (udg_TempLocation[2])
      • -------- ---- --------
      • -------- Start Move Beam --------
      • -------- ---- --------
      • Set TempLocation[1] = (Position of Ward[1])
      • Set TempLocation[3] = (TempLocation[1] offset by 200.00 towards (Facing of Ward[1]) degrees)
      • Unit - Move LB_BeamUnit_1[0] instantly to TempLocation[3]
      • Custom script: call RemoveLocation (udg_TempLocation[1])
      • Custom script: call RemoveLocation (udg_TempLocation[3])
      • -------- ---- --------
      • Set TempLocation[1] = (Position of Ward[1])
      • Set TempLocation[3] = (TempLocation[1] offset by 300.00 towards (Facing of Ward[1]) degrees)
      • Unit - Move LB_BeamUnit_1[1] instantly to TempLocation[3]
      • Custom script: call RemoveLocation (udg_TempLocation[1])
      • Custom script: call RemoveLocation (udg_TempLocation[3])
      • -------- ---- --------
      • Set TempLocation[1] = (Position of Ward[1])
      • Set TempLocation[3] = (TempLocation[1] offset by 400.00 towards (Facing of Ward[1]) degrees)
      • Unit - Move LB_BeamUnit_1[2] instantly to TempLocation[3]
      • Custom script: call RemoveLocation (udg_TempLocation[1])
      • Custom script: call RemoveLocation (udg_TempLocation[3])
      • -------- ---- --------
      • Set TempLocation[1] = (Position of Ward[1])
      • Set TempLocation[3] = (TempLocation[1] offset by 500.00 towards (Facing of Ward[1]) degrees)
      • Unit - Move LB_BeamUnit_1[3] instantly to TempLocation[3]
      • Custom script: call RemoveLocation (udg_TempLocation[1])
      • Custom script: call RemoveLocation (udg_TempLocation[3])
      • -------- ---- --------
      • Set TempLocation[1] = (Position of Ward[1])
      • Set TempLocation[3] = (TempLocation[1] offset by 600.00 towards (Facing of Ward[1]) degrees)
      • Unit - Move LB_BeamUnit_1[4] instantly to TempLocation[3]
      • Custom script: call RemoveLocation (udg_TempLocation[1])
      • Custom script: call RemoveLocation (udg_TempLocation[3])
      • -------- ---- --------
      • Set TempLocation[1] = (Position of Ward[1])
      • Set TempLocation[3] = (TempLocation[1] offset by 700.00 towards (Facing of Ward[1]) degrees)
      • Unit - Move LB_BeamUnit_1[5] instantly to TempLocation[3]
      • Custom script: call RemoveLocation (udg_TempLocation[1])
      • Custom script: call RemoveLocation (udg_TempLocation[3])
      • -------- ---- --------
      • Set TempLocation[1] = (Position of Ward[1])
      • Set TempLocation[3] = (TempLocation[1] offset by 800.00 towards (Facing of Ward[1]) degrees)
      • Unit - Move LB_BeamUnit_1[6] instantly to TempLocation[3]
      • Custom script: call RemoveLocation (udg_TempLocation[1])
      • Custom script: call RemoveLocation (udg_TempLocation[3])
      • -------- ---- --------
      • -------- End Move Beam 1 --------
      • -------- ---- --------
      • -------- Start Beam 2 --------
      • -------- ---- --------
      • Set TempLocation[1] = (Position of Ward[1])
      • Set TempLocation[2] = (TempLocation[1] offset by 100.00 towards ((Facing of Ward[1]) + 90.00) degrees)
      • Unit - Move Ward[3] instantly to TempLocation[2], facing (Facing of Ward[3]) degrees
      • Custom script: call RemoveLocation (udg_TempLocation[1])
      • Custom script: call RemoveLocation (udg_TempLocation[2])
      • -------- ---- --------
      • -------- Start Move Beam --------
      • -------- ---- --------
      • Set TempLocation[1] = (Position of Ward[1])
      • Set TempLocation[3] = (TempLocation[1] offset by 200.00 towards ((Facing of Ward[1]) + 90.00) degrees)
      • Unit - Move LB_BeamUnit_2[0] instantly to TempLocation[3]
      • Custom script: call RemoveLocation (udg_TempLocation[1])
      • Custom script: call RemoveLocation (udg_TempLocation[3])
      • -------- ---- --------
      • Set TempLocation[1] = (Position of Ward[1])
      • Set TempLocation[3] = (TempLocation[1] offset by 300.00 towards ((Facing of Ward[1]) + 90.00) degrees)
      • Unit - Move LB_BeamUnit_2[1] instantly to TempLocation[3]
      • Custom script: call RemoveLocation (udg_TempLocation[1])
      • Custom script: call RemoveLocation (udg_TempLocation[3])
      • -------- ---- --------
      • Set TempLocation[1] = (Position of Ward[1])
      • Set TempLocation[3] = (TempLocation[1] offset by 400.00 towards ((Facing of Ward[1]) + 90.00) degrees)
      • Unit - Move LB_BeamUnit_2[2] instantly to TempLocation[3]
      • Custom script: call RemoveLocation (udg_TempLocation[1])
      • Custom script: call RemoveLocation (udg_TempLocation[3])
      • -------- ---- --------
      • Set TempLocation[1] = (Position of Ward[1])
      • Set TempLocation[3] = (TempLocation[1] offset by 500.00 towards ((Facing of Ward[1]) + 90.00) degrees)
      • Unit - Move LB_BeamUnit_2[3] instantly to TempLocation[3]
      • Custom script: call RemoveLocation (udg_TempLocation[1])
      • Custom script: call RemoveLocation (udg_TempLocation[3])
      • -------- ---- --------
      • Set TempLocation[1] = (Position of Ward[1])
      • Set TempLocation[3] = (TempLocation[1] offset by 600.00 towards ((Facing of Ward[1]) + 90.00) degrees)
      • Unit - Move LB_BeamUnit_2[4] instantly to TempLocation[3]
      • Custom script: call RemoveLocation (udg_TempLocation[1])
      • Custom script: call RemoveLocation (udg_TempLocation[3])
      • -------- ---- --------
      • Set TempLocation[1] = (Position of Ward[1])
      • Set TempLocation[3] = (TempLocation[1] offset by 700.00 towards ((Facing of Ward[1]) + 90.00) degrees)
      • Unit - Move LB_BeamUnit_2[5] instantly to TempLocation[3]
      • Custom script: call RemoveLocation (udg_TempLocation[1])
      • Custom script: call RemoveLocation (udg_TempLocation[3])
      • -------- ---- --------
      • Set TempLocation[1] = (Position of Ward[1])
      • Set TempLocation[3] = (TempLocation[1] offset by 800.00 towards ((Facing of Ward[1]) + 90.00) degrees)
      • Unit - Move LB_BeamUnit_2[6] instantly to TempLocation[3]
      • Custom script: call RemoveLocation (udg_TempLocation[1])
      • Custom script: call RemoveLocation (udg_TempLocation[3])
      • -------- ---- --------
      • -------- End Move Beam 2 --------
      • -------- ---- --------
      • -------- Start Beam 3 --------
      • -------- ---- --------
      • Set TempLocation[1] = (Position of Ward[1])
      • Set TempLocation[2] = (TempLocation[1] offset by 100.00 towards ((Facing of Ward[1]) + 180.00) degrees)
      • Unit - Move Ward[4] instantly to TempLocation[2], facing (Facing of Ward[4]) degrees
      • Custom script: call RemoveLocation (udg_TempLocation[1])
      • Custom script: call RemoveLocation (udg_TempLocation[2])
      • -------- ---- --------
      • -------- Start Move Beam --------
      • -------- ---- --------
      • Set TempLocation[1] = (Position of Ward[1])
      • Set TempLocation[3] = (TempLocation[1] offset by 200.00 towards ((Facing of Ward[1]) + 180.00) degrees)
      • Unit - Move LB_BeamUnit_3[0] instantly to TempLocation[3]
      • Custom script: call RemoveLocation (udg_TempLocation[1])
      • Custom script: call RemoveLocation (udg_TempLocation[3])
      • -------- ---- --------
      • Set TempLocation[1] = (Position of Ward[1])
      • Set TempLocation[3] = (TempLocation[1] offset by 300.00 towards ((Facing of Ward[1]) + 180.00) degrees)
      • Unit - Move LB_BeamUnit_3[1] instantly to TempLocation[3]
      • Custom script: call RemoveLocation (udg_TempLocation[1])
      • Custom script: call RemoveLocation (udg_TempLocation[3])
      • -------- ---- --------
      • Set TempLocation[1] = (Position of Ward[1])
      • Set TempLocation[3] = (TempLocation[1] offset by 400.00 towards ((Facing of Ward[1]) + 180.00) degrees)
      • Unit - Move LB_BeamUnit_3[2] instantly to TempLocation[3]
      • Custom script: call RemoveLocation (udg_TempLocation[1])
      • Custom script: call RemoveLocation (udg_TempLocation[3])
      • -------- ---- --------
      • Set TempLocation[1] = (Position of Ward[1])
      • Set TempLocation[3] = (TempLocation[1] offset by 500.00 towards ((Facing of Ward[1]) + 180.00) degrees)
      • Unit - Move LB_BeamUnit_3[3] instantly to TempLocation[3]
      • Custom script: call RemoveLocation (udg_TempLocation[1])
      • Custom script: call RemoveLocation (udg_TempLocation[3])
      • -------- ---- --------
      • Set TempLocation[1] = (Position of Ward[1])
      • Set TempLocation[3] = (TempLocation[1] offset by 600.00 towards ((Facing of Ward[1]) + 180.00) degrees)
      • Unit - Move LB_BeamUnit_3[4] instantly to TempLocation[3]
      • Custom script: call RemoveLocation (udg_TempLocation[1])
      • Custom script: call RemoveLocation (udg_TempLocation[3])
      • -------- ---- --------
      • Set TempLocation[1] = (Position of Ward[1])
      • Set TempLocation[3] = (TempLocation[1] offset by 700.00 towards ((Facing of Ward[1]) + 180.00) degrees)
      • Unit - Move LB_BeamUnit_3[5] instantly to TempLocation[3]
      • Custom script: call RemoveLocation (udg_TempLocation[1])
      • Custom script: call RemoveLocation (udg_TempLocation[3])
      • -------- ---- --------
      • Set TempLocation[1] = (Position of Ward[1])
      • Set TempLocation[3] = (TempLocation[1] offset by 800.00 towards ((Facing of Ward[1]) + 180.00) degrees)
      • Unit - Move LB_BeamUnit_3[6] instantly to TempLocation[3]
      • Custom script: call RemoveLocation (udg_TempLocation[1])
      • Custom script: call RemoveLocation (udg_TempLocation[3])
      • -------- ---- --------
      • -------- End Move Beam 3 --------
      • -------- ---- --------
      • -------- Start Beam 4 --------
      • -------- ---- --------
      • Set TempLocation[1] = (Position of Ward[1])
      • Set TempLocation[2] = (TempLocation[1] offset by 100.00 towards ((Facing of Ward[1]) + 270.00) degrees)
      • Unit - Move Ward[5] instantly to TempLocation[2], facing (Facing of Ward[5]) degrees
      • Custom script: call RemoveLocation (udg_TempLocation[1])
      • Custom script: call RemoveLocation (udg_TempLocation[2])
      • -------- ---- --------
      • -------- Start Move Beam --------
      • -------- ---- --------
      • Set TempLocation[1] = (Position of Ward[1])
      • Set TempLocation[3] = (TempLocation[1] offset by 200.00 towards ((Facing of Ward[1]) + 270.00) degrees)
      • Unit - Move LB_BeamUnit_4[0] instantly to TempLocation[3]
      • Custom script: call RemoveLocation (udg_TempLocation[1])
      • Custom script: call RemoveLocation (udg_TempLocation[3])
      • -------- ---- --------
      • Set TempLocation[1] = (Position of Ward[1])
      • Set TempLocation[3] = (TempLocation[1] offset by 300.00 towards ((Facing of Ward[1]) + 270.00) degrees)
      • Unit - Move LB_BeamUnit_4[1] instantly to TempLocation[3]
      • Custom script: call RemoveLocation (udg_TempLocation[1])
      • Custom script: call RemoveLocation (udg_TempLocation[3])
      • -------- ---- --------
      • Set TempLocation[1] = (Position of Ward[1])
      • Set TempLocation[3] = (TempLocation[1] offset by 400.00 towards ((Facing of Ward[1]) + 270.00) degrees)
      • Unit - Move LB_BeamUnit_4[2] instantly to TempLocation[3]
      • Custom script: call RemoveLocation (udg_TempLocation[1])
      • Custom script: call RemoveLocation (udg_TempLocation[3])
      • -------- ---- --------
      • Set TempLocation[1] = (Position of Ward[1])
      • Set TempLocation[3] = (TempLocation[1] offset by 500.00 towards ((Facing of Ward[1]) + 270.00) degrees)
      • Unit - Move LB_BeamUnit_4[3] instantly to TempLocation[3]
      • Custom script: call RemoveLocation (udg_TempLocation[1])
      • Custom script: call RemoveLocation (udg_TempLocation[3])
      • -------- ---- --------
      • Set TempLocation[1] = (Position of Ward[1])
      • Set TempLocation[3] = (TempLocation[1] offset by 600.00 towards ((Facing of Ward[1]) + 270.00) degrees)
      • Unit - Move LB_BeamUnit_4[4] instantly to TempLocation[3]
      • Custom script: call RemoveLocation (udg_TempLocation[1])
      • Custom script: call RemoveLocation (udg_TempLocation[3])
      • -------- ---- --------
      • Set TempLocation[1] = (Position of Ward[1])
      • Set TempLocation[3] = (TempLocation[1] offset by 700.00 towards ((Facing of Ward[1]) + 270.00) degrees)
      • Unit - Move LB_BeamUnit_4[5] instantly to TempLocation[3]
      • Custom script: call RemoveLocation (udg_TempLocation[1])
      • Custom script: call RemoveLocation (udg_TempLocation[3])
      • -------- ---- --------
      • Set TempLocation[1] = (Position of Ward[1])
      • Set TempLocation[3] = (TempLocation[1] offset by 800.00 towards ((Facing of Ward[1]) + 270.00) degrees)
      • Unit - Move LB_BeamUnit_4[6] instantly to TempLocation[3]
      • Custom script: call RemoveLocation (udg_TempLocation[1])
      • Custom script: call RemoveLocation (udg_TempLocation[3])
      • -------- ---- --------
      • -------- End Move Beam 4 --------
      • -------- ---- --------
 
Whoaa, I'm not really sure what this is, but it looks to be like some sort of a projectile/missile system.

Maybe you can try doing something like this:

  • wack
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • For each (Integer LBeam1_IntegerLoop) from 0 to 6, do (Actions)
        • Loop - Actions
          • Set TempLocation[1] = (Position of Ward[1])
          • Set TempLocation[3] = (TempLocation[1] offset by 800.00 towards (Facing of Ward[1]) degrees)
          • Unit - Move LB_BeamUnit_1[LBeam1_IntegerLoop] instantly to TempLocation[3]
          • Custom script: call RemoveLocation(udg_TempLocation[1])
          • Custom script: call RemoveLocation(udg_TempLocation[3])
      • -------- Repeat the same trigger with different LBeam_IntegerLoops for each. --------
      • -------- By using Integer Loops, you can avoid repeating individual triggers --------
 
I can't see any leak. But yeh, you could look into Loops, to have more efficient code. There are also a lot of redundant function calls., like "Position of Ward" or "Angle of Ward" .. they do only need to be called once, and can be cached into a variable. It would boost performance a bit.

After a minute or more of having this active it takes a shit ton of time to exit the game.
Do you mean the black screen after game is long? Maybe there's an other trigger leaking? But it might also be a Warcraft problem, that it's a buggy patch, and the fault is not on your side. I also experienced long black screens randomly on non memory-leaking maps from code.
 
Whoaa, I'm not really sure what this is, but it looks to be like some sort of a projectile/missile system.

Maybe you can try doing something like this:

  • wack
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • For each (Integer LBeam1_IntegerLoop) from 0 to 6, do (Actions)
        • Loop - Actions
          • Set TempLocation[1] = (Position of Ward[1])
          • Set TempLocation[3] = (TempLocation[1] offset by 800.00 towards (Facing of Ward[1]) degrees)
          • Unit - Move LB_BeamUnit_1[LBeam1_IntegerLoop] instantly to TempLocation[3]
          • Custom script: call RemoveLocation(udg_TempLocation[1])
          • Custom script: call RemoveLocation(udg_TempLocation[3])
      • -------- Repeat the same trigger with different LBeam_IntegerLoops for each. --------
      • -------- By using Integer Loops, you can avoid repeating individual triggers --------
I could do that, I just really suck at loops which is why I didn't do it sooner :(

I can't see any leak. But yeh, you could look into Loops, to have more efficient code. There are also a lot of redundant function calls., like "Position of Ward" or "Angle of Ward" .. they do only need to be called once, and can be cached into a variable. It would boost performance a bit.


Do you mean the black screen after game is long? Maybe there's an other trigger leaking? But it might also be a Warcraft problem, that it's a buggy patch, and the fault is not on your side. I also experienced long black screens randomly on non memory-leaking maps from code.
The thing is that if I simply start the map and exit, the black screen won't come. If I start the map and activate ONLY this trigger and let it run for a while it will literally take ages for Warcraft to exit.

Also yeah I could, and should save the angles and so on to real variables.

I did actually only set position of ward once in the previous version of the trigger but changed to set it every time just to see if that fixed it.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,198
IMO: The problem is not leaks but the amount of location handles you allocate. Locations are costly so try to avoid them and replace them with real coordinates x, y) and use some math to generate the polar offset.
Unlikely the problem. If there are no leaks one can create any number of locations and performance should remain the same.
The thing is that if I simply start the map and exit, the black screen won't come. If I start the map and activate ONLY this trigger and let it run for a while it will literally take ages for Warcraft to exit.
Might be related to it running on null units. If it is part of an ability the units might not have been set to the arrays by the time it runs.

Might also be related to the way units are moved. Try the SetUnitX and SetUnitY function approach since that movement performs a lot fewer calculations.
 
Status
Not open for further replies.
Top