noob Question about Leaks

Aiden

Member
Reaction score
0
reading some tutorials
im trying to understand why some trigger couse some lag.
but i dont understand at all...

Events
Time - Every 1.00 seconds of game time
Conditions
Actions
Player Group - Pick every player in (REDTEAM) and do (Actions)
Loop - Actions
Player - Add 1 to (Picked player) Current gold


this will cause lag?
in all examples of memory leaks groups i saw generic group ...
if the answer its yes.
to remove this leaks i need to this?:
Set Temp_Group = (RedTEAM)
then in the end of the trigger
Custom script: call call DestroyGroup(udg_Temp_Point)

2)Second Question, i need to create for every trigger a new variable ? then destroy it?
like ... Temp_Point2,Temp_Point3,Temp_Point4 ....
 

Sgqvur

FullOfUltimateTruthsAndEt ernalPrinciples, i.e shi
Reaction score
62
>this will cause lag?
>to remove this leaks i need to this?:

Of course not...

>2)Second Question, i need to create for every trigger a new variable ? then destroy it?
like ... Temp_Point2,Temp_Point3,Temp_Point4 ....

No you need only one global Point(location in jass terms) variable called say 'Loc', or Temp_Point
for example.

You don't need to destroy Player Groups (Forces), you "need" to destroy unit groups and that's what DestroyGroup takes a unit group not a Point variable:

That's wrong:
Custom script: call DestroyGroup(udg_Temp_Point)

That's correct:
Custom script: call DestroyGroup(udg_Temp_Group)

Btw you fill the udg_Temp_Group variable with units with one of those Pick every unit in <something>.
 

tommerbob

Minecraft. :D
Reaction score
110
Player groups do leak. You can remove them with this:

Trigger:
  • Custom script: call DestroyForce(udg_Player_Group_Name)


However, you do not need to destroy the (all players) player group. If you do, you will likely end up with some funky bugs.
 

Inflicted

Currently inactive
Reaction score
63
This might not be what is causing the lag.

Disable this trigger and run, and then see if the lag is still there.
Otherwise just do what has been suggested above.
 

vypur85

Hibernate
Reaction score
803
> you need only one global Point

Not exactly.
It depends on situation.

Just remember you can reuse any variable after removing/destroying them.

An example:
Trigger:
  • Actions
    • Set TempPoint1 = (Position of (Triggering unit))
    • Set TempPoiint2 = TempPoint offset by 100.00 towards 0.00 degrees
    • ...do something...
    • Custom script: call RemoveLocation (udg_TempPoint1)
    • Custom script: call RemoveLocation (udg_TempPoint2)
    • Set TempPoint1 = (Position of (Triggering unit))
    • ...do something..
    • Custom script: call RemoveLocation (udg_TempPoint1)


TempPoint1 was reused and doesn't leak. In the above case, one variable just isn't enough. You need more than that.


And just for clarity. 'All players' does not leak. Other than that, they leak.
 

Aiden

Member
Reaction score
0
but its necesary?
i have a lot of this kind of trigger :
Player Group - Pick every player in Losbuenos[1] and do (Actions)
Loop - Actions
Unit Group - Pick every unit in (Units owned by (Picked player)) and do (Actions)
Loop - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
Then - Actions
Unit - Move (Picked unit) instantly to (Center of RedTeam Spawnpoint <gen>), facing (Position of (Triggering unit))
Unit - Remove All buffs from (Picked unit)
Selection - Select (Picked unit) for (Picked player)
Else - Actions
Do nothing
 

tommerbob

Minecraft. :D
Reaction score
110
You are leaking a lot in that trigger. You are leaking a unit group and 2 points for each enumerated unit in the group. Using the above trigger as an example, this is what it should look like:

Trigger:
  • Events
    • Conditions
    • Actions
      • Player group - Pick every player in losbuenos[1] and do (actions)
        • Loop - Actions
          • custom script set bj_wantDestroyGroup = true
          • Unit Group - Pick every unit in (Units owned by (Picked player)) and do (actions)
            • Loop - Actions
              • If (all conditions are true) then do (then actions) else do (else actions)
                • If - Conditions
                • Then - Actions
                  • Set Temp_Point1 = (center of RedTeam Spawnpoint &lt;gen&gt;)
                  • Set Temp_Point2 = (Position of (Triggering unit))
                  • Unit - Move (Picked unit) instantly to Temp_Point1 facing Temp_Point2
                  • Unit - Remove all buffs from (picked unit)
                  • Selection - Select (picked unit) for (picked player)
                  • Custom script: call RemoveLocation(udg_Temp_Point1)
                  • Custom script: call RemoveLocation(udg_Temp_Point2)
                • Else - Actions


Depending on how often you use the above trigger will depend on how much the game will lag over time. The more you leak over time, the more it will lag. A few leaks here and there will not make a difference, but it is good to clean them anyway. However, if you use a trigger like that one above often, it can start to lag the game over time, and this lag will multiply itself depending on how many players are in the Losbuenos[1] player group.
 

Aiden

Member
Reaction score
0
You are leaking a lot in that trigger. You are leaking a unit group and 2 points for each enumerated unit in the group. Using the above trigger as an example, this is what it should look like:

Trigger:
  • Events
    • Conditions
    • Actions
      • Player group - Pick every player in losbuenos[1] and do (actions)
        • Loop - Actions
        • <b> custom script set bj_wantDestroyGroup = true</b>
          • Unit Group - Pick every unit in (Units owned by (Picked player)) and do (actions)
            • Loop - Actions
              • If (all conditions are true) then do (then actions) else do (else actions)
                • If - Conditions
                • Then - Actions
                  • Set Temp_Point1 = (center of RedTeam Spawnpoint &lt;gen&gt;)
                  • Set Temp_Point2 = (Position of (Triggering unit))
                  • Unit - Move (Picked unit) instantly to Temp_Point1 facing Temp_Point2
                  • Unit - Remove all buffs from (picked unit)
                  • Selection - Select (picked unit) for (picked player)
                  • Custom script: call RemoveLocation(udg_Temp_Point1)
                  • Custom script: call RemoveLocation(udg_Temp_Point2)
                • Else - Actions


Depending on how often you use the above trigger will depend on how much the game will lag over time. The more you leak over time, the more it will lag. A few leaks here and there will not make a difference, but it is good to clean them anyway. However, if you use a trigger like that one above often, it can start to lag the game over time, and this lag will multiply itself depending on how many players are in the Losbuenos[1] player group.

What does that custom script ? =o
custom script set bj_wantDestroyGroup = true
 

Aiden

Member
Reaction score
0
> you need only one global Point

Not exactly.
It depends on situation.

Just remember you can reuse any variable after removing/destroying them.

An example:
Trigger:
  • Actions
    • Set TempPoint1 = (Position of (Triggering unit))
    • Set TempPoiint2 = TempPoint offset by 100.00 towards 0.00 degrees
    • ...do something...
    • Custom script: call RemoveLocation (udg_TempPoint1)
    • Custom script: call RemoveLocation (udg_TempPoint2)
    • Set TempPoint1 = (Position of (Triggering unit))
    • ...do something..
    • Custom script: call RemoveLocation (udg_TempPoint1)


TempPoint1 was reused and doesn't leak. In the above case, one variable just isn't enough. You need more than that.


And just for clarity. 'All players' does not leak. Other than that, they leak.
Other question.
my trigger event is this:
Trigger:
  • Events
    • Unit - A unit Dies

If i use a Custom script to destroy a variable, just like a point or playergroup, will works a second time when unit die?
sound more convenient to reuse, im right?
 

Aiden

Member
Reaction score
0
and in this case what i would do?
Trigger:
  • Balanced Gold
    • Events
      • Time - Every 7.00 seconds of game time
    • Conditions
    • Actions
      • Player Group - Pick every player in Losbuenos[1] and do (Actions)
        • Loop - Actions
          • Player - Add (42 / (Number of players in Losbuenos[1])) to (Picked player) Current gold
      • -------- Evil ones --------
      • Player Group - Pick every player in LosMalos[1] and do (Actions)
        • Loop - Actions
          • Player - Add (42 / (Number of players in LosMalos[1])) to (Picked player) Current gold
 

tommerbob

Minecraft. :D
Reaction score
110
Nothing. You are using player groups, that is different from unit groups.

As long as you are reusing the same player group instead of constantly creating new ones, you are fine.
 
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