• 🏆 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!

[Trigger] Trigger leaking like hell

Status
Not open for further replies.
Level 4
Joined
Mar 24, 2008
Messages
87
Hi, i'm wondering why my trigger is leaking, as i'm destroying groups and locations. Is it the fact i use "Unit-type" in my conditions ?

  • H Demo follow
    • Events
    • Conditions
    • Actions
      • For each (Integer A) from 1 to 10, do (Actions)
        • Boucle - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Or - Any (Conditions) are true
                • Conditions
                  • (Number of living Chien des enfers units owned by (Player((Integer A)))) > 0
                  • (Number of living Guerrier squelette units owned by (Player((Integer A)))) > 0
                  • (Number of living Mage squelette units owned by (Player((Integer A)))) > 0
                  • (Number of living Archer squelette units owned by (Player((Integer A)))) > 0
            • Then - Actions
              • Set PointTemp2 = (Position of Heroes[(Integer A)])
              • Set GroupeTemp1 = (Units owned by (Player((Integer A))) matching ((((Matching unit) is alive) = TRUE) and ((((Unit-type of (Matching unit)) = Guerrier squelette) or ((Unit-type of (Matching unit)) = Chien des enfers)) or (((Unit-type of (Matching unit)) = ...
              • Unit group - Pick every unit in GroupeTemp1 and do (Actions)
                • Boucle - Actions
                  • Set PointTemp1 = (Position of (Picked unit))
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Distance between PointTemp1 and PointTemp2) >= 1500.00
                    • Then - Actions
                      • Custom script: call RemoveLocation (udg_PointTemp1)
                      • Set PointTemp1 = (PointTemp2 offset by 100.00 towards (Facing of Heroes[(Integer A)]) degrees)
                      • Unit - Move (Picked unit) instantly to PointTemp2
                      • Unit - Order (Picked unit) to Stop
                    • Else - Actions
                  • Custom script: call RemoveLocation (udg_PointTemp1)
              • Custom script: call DestroyGroup (udg_GroupeTemp1)
              • Custom script: call RemoveLocation (udg_PointTemp2)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Remaining time for ZDemoCompteurAttaque[(Integer A)]) = 0.00
                • Then - Actions
                  • Set PointTemp1 = (Position of Heroes[(Integer A)])
                  • Set PointTemp2 = (PointTemp1 offset by 100.00 towards ((Facing of Heroes[(Integer A)]) + 90.00) degrees)
                  • Set GroupeTemp1 = (Units owned by (Player((Integer A))) matching ((((Matching unit) is alive) = TRUE) and (((Unit-type of (Matching unit)) = Guerrier squelette) or (((Unit-type of (Matching unit)) = Mage squelette) or ((Unit-type of (Matching unit)) Egal = ...
                  • Groupe unit - Pick every unit in GroupeTemp1 and do (Actions)
                    • Boucle - Actions
                      • Unit - Order (Picked unit) to Go to PointTemp2
                  • Custom script: call RemoveLocation (udg_PointTemp1)
                  • Custom script: call RemoveLocation (udg_PointTemp2)
                  • Custom script: call DestroyGroup (udg_GroupeTemp1)
                • Else - Actions
            • Else - Actions
Using a global event : every 0.03 second.

This trigger, with 2 other ones, is made to creat an AI for summoned minions. This one TP them if they are too far from the hero, or order them to "follow" him if he is not attacking (He is concidered not attacking after 3 sec. : i use ZDemoCompteurAttaque[X] for this)

If you need more infos just ask.

Where are leaks please :D

Thanks in advance !
 
Level 29
Joined
Oct 24, 2012
Messages
6,543
it doesnt look like its leaking unless i missed something. u should make a temp integer and use that instead of integer A. integer A is slower and can cause bugs.

Also it looks like u added each action by urself so here is this http://www.hiveworkshop.com/forums/miscellaneous-tutorials-456/how-easily-post-triggers-163285/

Turn off this trigger to make sure it's the one leaking. Also make sure it runs from start to end. if it has a bug and stops b4 it cleans the leaks that could be the problem.

Also null the variables after u remove them
 
Level 7
Joined
Jan 22, 2013
Messages
293
Another problem I see that is rather bold for you not to do is that after you remove/destroy a location/group you should null them. Here are the Triggers for that, place place them where you have all of your custom script (AFTER YOU REMOVE THAT Custom script I showed you inside that "Then - Custom Script trigger)

  • Custom script: set udg_PointTemp1 = null
  • Custom script: set udg_PointTemp2 = null
  • Custom script: set udg_GroupeTemp1 = null
And ty for the thanks in advance lol.

These should always be followed directly after you remove any sort of Leak
 
Level 4
Joined
Mar 24, 2008
Messages
87
First of all : thanks for taking time to answer.

@death : I'm 100% sure this trigger leaks, as before : no leak, then turning it on : a lot of leaks. (i use http://www.hiveworkshop.com/forums/general-mapping-tutorials-278/debugging-188204/ post's method to check leaks).

For interger A, you mean i'll have, each time i use one, to make it a Temp integer, and then to use it in instead of the "Integer A" ?

No didn't add each actions, it's just that copy / pasting triggers from my worldedit make weird characters sometimes, and moreover i think it's easier for people to read english than french trigger :p So after each copy / past i try making it look better.

@both : Is it necessary to make variables null each time i destroy them ? I mean, each trigger using them will give a new value (or creat them) before any use, so why would i have to make them null ?
 
Level 7
Joined
Jan 22, 2013
Messages
293
First of all : thanks for taking time to answer.

@death : I'm 100% sure this trigger leaks, as before : no leak, then turning it on : a lot of leaks. (i use http://www.hiveworkshop.com/forums/general-mapping-tutorials-278/debugging-188204/ post's method to check leaks).

For interger A, you mean i'll have, each time i use one, to make it a Temp integer, and then to use it in instead of the "Integer A" ?

No didn't add each actions, it's just that copy / pasting triggers from my worldedit make weird characters sometimes, and moreover i think it's easier for people to read english than french trigger :p So after each copy / past i try making it look better.

@both : Is it necessary to make variables null each time i destroy them ? I mean, each trigger using them will give a new value (or creat them) before any use, so why would i have to make them null ?

If you still have leaks send me a copy of your triggers or the map in Private message I will seek and destroy your problems.


Call RemoveLocaiton < That removes the leak
set udg_yourvariable = null < That Whipes the leak from existence. I'd say yes.


IntegerA is slow (meaning it takes up more of your FPS when you run the spell. Meaning it lags more if you don't use a custom integer.

Don't worry what the integer is set at or setting it to anything, it works exactly like integer only with way less Lag.
 
Level 29
Joined
Oct 24, 2012
Messages
6,543
Level 4
Joined
Mar 24, 2008
Messages
87
Oh i see ! Thanks, really didn't know for leaks, ill add custom script to make them null everywhere so :p

Same for interger A, gonna change triggers using it.

But at the moment the most important thing is to clear leaks from this trigger, imo, as running every 0.03sec, it makes huge lags !

Still leaking :/ I think i'll send the trigger by mp !
 
Level 4
Joined
Mar 24, 2008
Messages
87
Here is the map :

  • X Zero zero trois sec periode H
    • Evénements
      • Temps - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • Déclencheur - Run H Charge de mana move effect <gen> (checking conditions)
      • Déclencheur - Run H Charge en cours <gen> (checking conditions)
      • Déclencheur - Run H Marteau beni ON <gen> (checking conditions)
      • Déclencheur - Run H Orbe de glace MOVE <gen> (checking conditions)
      • Déclencheur - Run H Volee de fleches ON <gen> (checking conditions)
      • Déclencheur - Run H Tornade ON <gen> (checking conditions)
      • Déclencheur - Run H Rayon de givre Effect <gen> (checking conditions)
      • Déclencheur - Run H Demo follow <gen> (checking conditions)
Is the event for triggers leaking at the moment, and :
JASS:
function HandleCount takes nothing returns nothing
    local location L = Location(0,0)
    call BJDebugMsg(I2S(GetHandleId(L)-0x100000))
    call RemoveLocation(L)
    set L = null
endfunction

//===========================================================================
function InitTrig_HandleCounter takes nothing returns nothing
    local trigger t = CreateTrigger()
    call TriggerRegisterTimerEvent(t,0.09,true)
    call TriggerAddAction(t,function HandleCount)
endfunction

Is the trigger to check leaks.

Thank you guys !

Edit : forgot linking the map ^^"
 

Attachments

  • HnS.w3x
    684.4 KB · Views: 47
Last edited by a moderator:
Level 37
Joined
Mar 6, 2006
Messages
9,240
Player group leaks

  • (Number of players in (All players matching..
  • Game - Display to (Player group((Triggering player))) the text...

Unit group leak

  • Unit Group - Pick every unit in (Units in Choix heros <gen>)...
Every unique string causes a "leak" since the game stores it and you can't avoid that.
 
Level 4
Joined
Mar 24, 2008
Messages
87
Thanks Maker, but i know there are other leaks in my maps :p
I mean i will fix these ones after, as at the moment the ones with the 0.03 sec event are the more important ! (So : the trigger i linked at the begining of the post : H Demo follow)

Hope i didn't missunderstand you.

Anyway thank you for answer + editing :)

Edit : i found the first leak : using these conditions make the trigger leaking
  • Or - Any (Conditions) are true
  • Conditions
  • (Number of living Chien des enfers units owned by (Player((Integer A)))) > 0
  • (Number of living Guerrier squelette units owned by (Player((Integer A)))) > 0
  • (Number of living Mage squelette units owned by (Player((Integer A)))) > 0
  • (Number of living Archer squelette units owned by (Player((Integer A)))) > 0
Also, the TempGroup1 seems to leak.

I have a question ; how to pick every unit of a chosen Unit-type, put them into a group and then use it for some kind of actions without creating a leak ?
 
Last edited:
Level 4
Joined
Jan 27, 2010
Messages
133
Instead of making 4+1 group, just make 1...?

  • Set GroupeTemp1 = (Units owned by (Player((Integer A))) matching ((((Matching unit) is alive) = TRUE) and ((((Unit-type of (Matching unit)) = Guerrier squelette) or ((Unit-type of (Matching unit)) = Chien des enfers)) or (((Unit-type of (Matching unit)) = ...
  • If - Conditions
    • Or - Any (Conditions) are true
      • Conditions
        • (Number of units in GroupeTemp1) > 0
    • Then - Actions
 
Level 4
Joined
Mar 24, 2008
Messages
87
Unit-type in "matching unit" seems to leak, so even this way isn't good :/

Ok, i feel like i mess something about Unit group leaks...

Just an example, why does this trigger leak ?
  • Déclencheur sans titre 001
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • Set GroupeTemp1 = (Units in (Entire map))
      • Custom script: call DestroyGroup (udg_GroupeTemp1)
      • Custom script: set udg_GroupeTemp1 = null
 
Level 4
Joined
Jan 27, 2010
Messages
133
Try this:
  • Set RectTemp = (Entire map)
  • Set GroupeTemp1 = (Units in RectTemp)
  • Custom script: call RemoveRect(udg_RectTemp)
  • Custom script: call DestroyGroup (udg_GroupeTemp1)
As for your other problem; perhaps you can add the units to a group when they enter the battlefield and remove them when they die? (So long as you don't have revive it should work just fine)

  • Event
    • Unit enters battlefield
  • Conditions
    • Or
      • Unit Type of (Triggering Unit) equals to Le baguette
      • Unit Type of (Triggering Unit) equals to Chien
      • etc..
  • Actions
    • Unit Group - Add (Triggering Unit) to PlayerGroup[(Get Player Id)]
Then count units in that group...
 
Level 4
Joined
Mar 24, 2008
Messages
87
Thaught about it, but it makes everything much harder, as i use many GroupTemp in my spells...

And tryed it : still leaking.

I must missunderstand something, checking over and over tutos but i don't get it -.-"
 
Level 4
Joined
Jan 27, 2010
Messages
133
Are you using a handle counter to discover leaks...? Or are you carefully monitoring warcraft's memory usage over a longer period of time?

Thing is, so long as you remember to destroy every group and point (and effect, and rect, etc.) that you create, you are actually fine. Every Pick all units... creates a group, and needs to be followed by a DestroyGroup eventually. The exception is if a group is supposed to last the entire game. Then you ofc. do not need to destroy it.

  • (Pick All Units ...)
Will always cause the handle count to rise. BUT. If you destroy the group you won't leak any memory.
 
Level 4
Joined
Mar 24, 2008
Messages
87
Yes, i was using a handle count.
So even if it's rising, this doesn't mean i have leaks ? (missunderstood the Debugging post then)

Is having a high handle count a problem for a map ?

And, is there any other way to check if my map has leaks ?
 
Level 4
Joined
Jan 27, 2010
Messages
133
If you use purely JASS/vJASS/etc, a handle counter can acurrately tell you if there are leaks. GUI has some functions that never re-index Handle ID's, so you can expect the handle counter's value to rise.

Is having a high handle count a problem for a map ?
Blizzard has that in their maps. I'd say it's not a problem.

You can watch the memory usage of warcraft (I assume you run Windows): Ctrl+Alt+Delete - Taskmanager - Processes - war3.exe. Make a sterile test map containing code that you are unsure about, then loop it like hell (For integer 0 - 100, every 0.01 seconds). The important thing is to let it run for a while, and look out for BIG differences.
 
Level 4
Joined
Mar 24, 2008
Messages
87
I'm using only GUI atm. I'll seriously have to learn Jass -.-"

Thx for the way to check leaks, but i must admit that'll take a lot of time for each trigger !
I thaught a trigger could check it, or just a prog :/

Anyway, thx for answers !
 

Zwiebelchen

Hosted Project GR
Level 35
Joined
Sep 17, 2009
Messages
7,236
Instead of enumerating the number of units per type in the map every time, store the count to an integer and count yourself.

Create an event "unit enters rect - entire map rect" and check which type it is, then increment the counter for it (note: this doesn't catch preplaced units, so count them by an enumeration on map init!).
Then all you need to do in your conditions is using the counter instead of enumerating again.
Other than those conditions, you don't leak.
 
Status
Not open for further replies.
Top