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 ....
 
>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>.
 
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.
 
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.
 
> 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.
 
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
 
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.
 
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
 
> 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?
 
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
 
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.
  • V-SNES V-SNES:
    Happy Friday!
    +1
  • The Helper The Helper:
    News portal has been retired. Main page of site goes to Headline News forum now
  • The Helper The Helper:
    I am working on getting access to the old news portal under a different URL for those that would rather use that for news before we get a different news view.
  • Ghan Ghan:
    Easily done
    +1
  • The Helper The Helper:
    https://www.thehelper.net/pages/news/ is a link to the old news portal - i will integrate it into the interface somewhere when i figure it out
  • Ghan Ghan:
    Need to try something
  • Ghan Ghan:
    Hopefully this won't cause problems.
  • Ghan Ghan:
    Hmm
  • Ghan Ghan:
    I have converted the Headline News forum to an Article type forum. It will now show the top 20 threads with more detail of each thread.
  • Ghan Ghan:
    See how we like that.
  • The Helper The Helper:
    I do not see a way to go past the 1st page of posts on the forum though
  • The Helper The Helper:
    It is OK though for the main page to open up on the forum in the view it was before. As long as the portal has its own URL so it can be viewed that way I do want to try it as a regular forum view for a while
  • Ghan Ghan:
    Yeah I'm not sure what the deal is with the pagination.
  • Ghan Ghan:
    It SHOULD be there so I think it might just be an artifact of having an older style.
  • Ghan Ghan:
    I switched it to a "Standard" article forum. This will show the thread list like normal, but the threads themselves will have the first post set up above the rest of the "comments"
  • The Helper The Helper:
    I don't really get that article forum but I think it is because I have never really seen it used on a multi post thread
  • Ghan Ghan:
    RpNation makes more use of it right now as an example: https://www.rpnation.com/news/
  • The Helper The Helper:
  • The Helper The Helper:
    What do you think Tom?
  • tom_mai78101 tom_mai78101:
    I will have to get used to this.
  • tom_mai78101 tom_mai78101:
    The latest news feed looks good

      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