Help with memory leak

Feralex

Active Member
Reaction score
4
This trigger works as intended but when a unit owned by player 5 is ordered an order many many time over it causes the game to lag after a while but i cant see why. The Point variable is destroyed and as far as i can see its the only thing that possibly can cause a memory leak. "CenterofMap" is a point variable created at the initialization of the map.

Code:
YellowRing
    Events
        Advanced - Any Unit is Issued Any Order
    Conditions
        (Owner of (Ordered unit)) Equal to Player 5 (Yellow)
    Actions
        Wait 0.01 seconds
        Set Yellowunitpoint = (CenterofMap offset by (YellowRX[(Custom value of (Ordered unit))], YellowRY[(Custom value of (Ordered unit))]))
        Unit - Move (Ordered unit) instantly to Yellowunitpoint, facing YellowRangle[(Custom value of (Ordered unit))] degrees
        Point - Remove Yellowunitpoint

I dont know if this is necasary to show but its connected to the previous trigger. Its basically a slightly remade respawning-trigger to save the position and facing of all units owned by player 5.

Code:
YellowR
    Events
        Map initialization
    Conditions
    Actions
        Set YellowRgroup = (Units owned by Player 5 (Yellow))
        Unit Group - Pick every unit in YellowRgroup and do (Actions)
            Loop - Actions
                Set YellowRint = (YellowRint + 1)
                Unit - Set the custom value of (Picked unit) to YellowRint
                Custom script: set udg_YellowRX[udg_YellowRint] = GetUnitX(GetEnumUnit())
                Custom script: set udg_YellowRY[udg_YellowRint] = GetUnitY(GetEnumUnit())
                Set YellowRangle[YellowRint] = (Facing of (Picked unit))
        Unit Group - Destroy unit group YellowRgroup
 

the_ideal

user title
Reaction score
61
Try replacing ordered unit with triggering unit. This may not be the problem, but ordered unit can get lost in a trigger. Whenever possible, use triggering. Other than that, I can't see what's going wrong. (I'm not much of an expert on leaks, though)
 

Feralex

Active Member
Reaction score
4
thanks for the tip but as you said it didnt help the leak.
Still need help!
 

vypur85

Hibernate
Reaction score
803
Code:
YellowRing
    Events
        Advanced - Any Unit is Issued Any Order
    Conditions
        (Owner of (Ordered unit)) Equal to Player 5 (Yellow)
    Actions
        Trigger - Turn off (This trigger)
        Set Yellowunitpoint = (CenterofMap offset by (YellowRX[(Custom value of (Ordered unit))], YellowRY[(Custom value of (Ordered unit))]))
        Unit - Move (Ordered unit) instantly to Yellowunitpoint, facing YellowRangle[(Custom value of (Ordered unit))] degrees
        Point - Remove Yellowunitpoint
        Trigger - Turn on (This trigger)

Remove the wait. Then turn the trigger on and off. It lagged because everytime you move a unit to a position, the unit will be autamatically ordered to 'stop' which in this case, fires the event again. (If you didn't add the wait, I think it would cause error. But since you added the wait, it only caused extreme lag).
 

Feralex

Active Member
Reaction score
4
Ive tried that now in every possible combination but it either doesnt do anything at all or it causes the game to crash. Like you said, when i remove the wait it causes the game to instantly crash because it loops infinatly.
So the problem still remains
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      • Ghan
        Administrator - Servers are fun

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top