Memory Leak/Lag Help

Status
Not open for further replies.
Level 13
Joined
Sep 25, 2013
Messages
717
Hi!
Ive been working on my LOTR Builder map for a while now but i've been having problems with lag. Most games at least 1 or 2 players will lag terribly and I myself often lag when playing my game. I tried my best to fix memory leaks but I'm not an expert. Could someone look at my triggers, probably the periodic event triggers mostly, and see if they can find something that would cause lag? I would really appreciate some help on this.

here is the link to my map: http://www.hiveworkshop.com/forums/maps-564/lord-rings-builder-v-1-4-a-265606/?prev=r=20&page=4

If i could just fix the lag then I would be satisfied
 
Level 25
Joined
May 11, 2007
Messages
4,650
You do already remove leaks in some triggers, by destroying groups and you do remove locations in some triggers.

You just.. doesn't do it all triggers for some reasons.

EVERY time you use a point, say creating a unit or so, it should be using a variable called tempPoint1, and then you remove said tempPoint1 after using it.

Like you have done in the trigger Moria Support Beam 1.
 
Big maps are not rarely pre-destinated to cause lags when playing with too many units.
It is be because of the often usage "PickEveryUnitInMap" opereation. People like to use it for many tasks to solve,
but the problem is that it's too heavy if called too often in low time intervals, and this with a huge amount of units in map.

I often saw it people just use it for any kind of trigger, because it's not difficult to use.
SoI want say if there are too many triggers that frequently use it, it's quite certain that it will cause lags.

(you might have leaks, too, yes, but effect of leaks usually comes by time and is permanently increasing)
 
Level 37
Joined
Mar 6, 2006
Messages
9,243
Market Cast and Market Cast 2 triggers are leaking badly and the run very often. Swan Knight Glorious Charge leaks, the offset point should be removed inside the unit group loop.

Shield Breaker Stone Formation leaks badly, location and a unit group when setting the integer.

There are tons of other leaks also, check every trigger.
 
Level 13
Joined
Sep 25, 2013
Messages
717
I have moved the offset point from the loop, where else does this trigger leak?


  • Swan Knight Glorious Charge
    • Events
      • Time - Every 0.10 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in SwanKnightUnitGroup and do (Actions)
        • Loop - Actions
          • Set SwanKnightRemainingTime = (Load 0 of (Key (Picked unit)) from SwanKnightHashtable)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • SwanKnightRemainingTime Greater than 0
            • Then - Actions
              • Hashtable - Save (SwanKnightRemainingTime - 1) as 0 of (Key (Picked unit)) in SwanKnightHashtable
              • Set RohanRider = (Picked unit)
              • Set RohanTrampleUnitPoint = (Position of (Picked unit))
              • Set TrampledUnitsGroup = (Units within 130.00 of RohanTrampleUnitPoint matching ((((Matching unit) is A structure) Equal to False) and ((((Matching unit) belongs to an enemy of (Owner of (Picked unit))) Equal to True) and ((((Matching unit) is A Hero) Equal to False) and ((((Matching
              • Set RohanTrampleUnitPointOffset = (RohanTrampleUnitPoint offset by 250.00 towards (Angle from RohanTrampleUnitPoint to (Position of RohanTrampleUnit)) degrees)
              • Special Effect - Create a special effect attached to the origin of RohanRider using Objects\Spawnmodels\Undead\ImpaleTargetDust\ImpaleTargetDust.mdl
              • Special Effect - Destroy (Last created special effect)
              • Unit Group - Pick every unit in TrampledUnitsGroup and do (Actions)
                • Loop - Actions
                  • Unit - Move (Picked unit) instantly to RohanTrampleUnitPointOffset, facing (Position of RohanRider)
                  • Unit - Order (Picked unit) to Stop
                  • Special Effect - Create a special effect attached to the chest of RohanTrampleUnit using Abilities\Spells\Human\Defend\DefendCaster.mdl
                  • Special Effect - Destroy (Last created special effect)
              • Custom script: call DestroyGroup (udg_RohanRiderGroup)
              • Custom script: call DestroyGroup (udg_TrampledUnitsGroup)
              • Custom script: call RemoveLocation (udg_RohanTrampleUnitPoint)
              • Custom script: call RemoveLocation (udg_RohanTrampleUnitPointOffset)
            • Else - Actions
              • Unit - Remove Trample (Swan Knight) from (Picked unit)
              • Unit Group - Remove (Picked unit) from SwanKnightUnitGroup
              • Hashtable - Clear all child hashtables of child (Key (Picked unit)) in SwanKnightHashtable
Also, I don't understand what leaks in the Stone Formation trigger. I added the tempunitgroup2 so that the Shield breaker integer references it so that I can remove the group later.

  • Shield Breaker Stone Formation
    • Events
      • Time - Every 0.50 seconds of game time
    • Conditions
    • Actions
      • Set tempUnitGroup = (Units in (Playable map area) matching (((Unit-type of (Matching unit)) Equal to Shield Breaker |c00FFFF00(Elite)|r (Dwarves)) and (((Matching unit) is alive) Equal to True)))
      • Unit Group - Pick every unit in tempUnitGroup and do (Actions)
        • Loop - Actions
          • Set tempUnitGroup2 = (Units within 500.00 of (Position of (Picked unit)) matching (((Unit-type of (Matching unit)) Equal to Shield Breaker |c00FFFF00(Elite)|r (Dwarves)) and (((Owner of (Matching unit)) Equal to (Owner of (Picked unit))) and (((Matching unit) is alive) Equal to T
          • Set ShieldBreakerInteger = (Number of units in tempUnitGroup2)
          • Unit - Set level of Stone Formation (Shield Breaker) for (Picked unit) to ShieldBreakerInteger
      • Custom script: call DestroyGroup (udg_tempUnitGroup)
      • Custom script: call DestroyGroup (udg_tempUnitGroup2)
 
Last edited by a moderator:
Level 25
Joined
May 11, 2007
Messages
4,650
For the Shield Breaker Stone Formation, you need to move the Custom script: call DestroyGroup (udg_tempUnitGroup2) into your pick every unit loop, as you are creating an unit group for every picked unit.
 
Status
Not open for further replies.
Top