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

Things That Leak

Level 12
Joined
Apr 27, 2008
Messages
1,228
He leaks 1 location in first trigger:
Jumploc[1]
You do not have to null global variables(last trigger).
 
Level 13
Joined
Nov 22, 2006
Messages
1,260
Silvenon to the rescue!!!

Destroy Jumploc at the end of the first trigger.

Btw, why are you destroying Jumpland location in the Land1 trigger? You can destroy it in the first trigger along with Jumploc, because only thing you're using that location for is to measure distance....

Those are all the leaks as far as I can see, air1 trigger doesn't leak at all, everything should be ok.


P.S. You should not spam that spell because it isn't MUI (that would cause leaks), but you probably already know that.....
 
I'll tell u guys the funny thing.

@ silvenon i did, ther were no leaks, yes its not MUI but is PUI so thats all that matters.


anyway. apparently, my base ability, was shockwave, and if u removed all the integers from the data it lagged like hell and leaked.

i changed the base abil to flare and now the leaking is gone, no more lag XD

EDIT: btw the trigger doesn't look like the one i posted anymore so dont say anything now.
 
Level 12
Joined
Aug 20, 2007
Messages
866
OMG DER PWNZORZ!!

Spendin' time in the something else thread

Yeah, PUI actually means Player Unit Instance-able, because it is supposed to be used for single unit maps, like dodgeball maps

I can't add anything intelligent
 
if you are looking for things that leak:
Local Var Leaks - Wc3campaigns

Also, remember to include dynamic triggers:
Why are dynamic triggers evil ? - Wc3campaigns

Also, timers and groups also leak. However a way to optimize the whole process and preventing them from leaking is use a recycling system, such as CSSafety.
Also units can also be recycled, although that i not common.

Also Garbage collector is from Java, not from JASS, although it would've been a nice idea =D
Garabage collector searches periodically all your variables, to see if:
- they have a reference to some position in memory
- if that reference is being used or is likely to be used
If not, they are cleaned.

Hope I helped you all with my experience =)
 
Level 13
Joined
Nov 22, 2006
Messages
1,260
Oh, sorry, I didn't know.

That can be a serious bug, you could study it further, find out what exactly is happening and post it somewhere (because I don't thing such a bug has been found yet).

I thought PUI stands for Perfect Unit Indexing.... :p
 
Level 11
Joined
Dec 31, 2007
Messages
780
wich one leaks?

  • Unit Group - Pick every unit in UnitGroup[93] and do (Actions)
    • Loop - Actions
      • Player - Enable Sagitarius Arrow ( Aioros de Sagitário ) for (Owner of (Picked unit))
      • Player - Enable Serpent Ward (Rokhan) for (Owner of (Picked unit))
      • Player - Enable Summon Bloody Trap of Acheron (Chaotic) for (Owner of (Picked unit))
      • Player - Enable Starlight Extinction (Aries_Mu) for (Owner of (Picked unit))
  • Custom script: call DestroyGroup(udg_UnitGroup[93])

  • Player Group - Pick every player in (All players) and do (Player - Enable Unstoppable Strength (Taurus Aldebaran)(Avatar) for (Picked player))

now... if the second one leaks... (it is all players) but if it leaks... and i have 50+ of this ones... should i place only one
  • call DestroyForce(udg_PlayerGroup)
or 50 of them... one under every player group?... imagine that this trigger executes more than 6 times per game... twice every time... (that makes 12+ executions per game) and for 50+ skills... making a huge amount of 600+~700+ per game... in very long games will make an amount of 2300+ times... imagine one leak with this numbers and my complain about this
 
Level 11
Joined
Dec 31, 2007
Messages
780
Thank god!

well... as im at work right now... i dont have my other trigger... but in a couple of hours im gonna post 2 triggers that i think they leak... one is for sure leaking

thx

EDIT: here they go

  • XP for Kanon heroes
    • Events
      • Unit - A unit Dies
    • Conditions
      • ((Triggering unit) is A Hero) Equal to True
      • ((Triggering unit) belongs to an enemy of (Owner of Gemini Kanon 0049 <gen>)) Equal to True
      • ((Region centered at (Position of Gemini Kanon 0049 <gen>) with size (900.00, 900.00)) contains (Triggering unit)) Not equal to True
    • Actions
      • Wait until (XP_Giving Equal to False), checking every 0.20 seconds
      • Set XP_Giving = True
      • Set Location3[49] = (Position of (Triggering unit))
      • Set UnitGroup2[38] = (Units in (Playable map area) matching ((((Matching unit) is A Hero) Equal to True) and (((Matching unit) Not equal to Gemini Kanon 0049 <gen>) and ((((Matching unit) is alive) Equal to True) and (((Matching unit) belongs to an ally of (Owner of Gemini Kanon
      • Unit Group - Pick every unit in UnitGroup2[38] and do (Actions)
        • Loop - Actions
          • Set XP_HeroNumberDivider = (XP_HeroNumberDivider + 1)
      • Set XP_HeroNumberDivider = (XP_HeroNumberDivider + 1)
      • Hero - Add (Hero_XP_Given[(Hero level of (Triggering unit))] / XP_HeroNumberDivider) experience to Gemini Kanon 0049 <gen>, Show level-up graphics
      • Set XP_HeroNumberDivider = 0
      • Set XP_Giving = False
      • Custom script: call RemoveLocation(udg_Location3[49])
      • Custom script: call DestroyGroup(udg_UnitGroup2[38])
by the time i created this trigger i didnt know how to remove region leaks... now i know... so i should set the region inside the trigger and place the "region contains dying unit" condition inside an IF inside the trigger to make it leakless?... am i correct?


  • Sagitarius Arrow Movement
    • Events
      • Time - Every 0.04 seconds of game time
    • Conditions
    • Actions
      • Set Location3[62] = (Position of Sagitarius_Arrow_Dummy)
      • Set Location3[63] = (Position of Sagitarius_Arrow_Targ)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Distance between Location3[62] and Location3[63]) Greater than or equal to 40.00
        • Then - Actions
          • Unit - Move Sagitarius_Arrow_Dummy instantly to (Location3[62] offset by 30.00 towards (Angle from Location3[62] to Location3[63]) degrees)
          • If (((Current flying height of Sagitarius_Arrow_Dummy) Less than or equal to 300.00) and ((Distance between Location3[62] and Location3[63]) Greater than or equal to 2000.00)) then do (Animation - Change Sagitarius_Arrow_Dummy flying height to ((Current flying height of Sagitarius_Arrow_Dummy) + 100.00) at 200.00) else do (Do nothing)
          • If (((Current flying height of Sagitarius_Arrow_Dummy) Greater than or equal to 200.00) and ((Distance between Location3[62] and Location3[63]) Less than 2000.00)) then do (Animation - Change Sagitarius_Arrow_Dummy flying height to ((Current flying height of Sagitarius_Arrow_Dummy) - 100.00) at 200.00) else do (Do nothing)
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Sagitarius_Arrow_Targ is in Spell_Imunity_Group) Not equal to True) and (((Sagitarius_Arrow_Targ is Magic Immune) Not equal to True) and ((Sagitarius_Arrow_Targ is in SleepingGroup) Not equal to True))
            • Then - Actions
              • Unit - Grant shared vision of Sagitarius_Arrow_Targ to (Owner of Sagitarius_Arrow_Dummy)
              • Unit - Order Sagitarius_Arrow_Dummy to Stop
              • Unit - Order Sagitarius_Arrow_Dummy to Human Mountain King - Storm Bolt Sagitarius_Arrow_Targ
              • Wait until (Sagitarius_Arrow_Casted Equal to True), checking every 0.10 seconds
              • Unit - Kill Sagitarius_Arrow_Dummy
              • Unit - Remove Sagitarius_Arrow_Dummy from the game
              • Unit - Deny shared vision of Sagitarius_Arrow_Targ to (Owner of Sagitarius_Arrow_Dummy)
              • Set Sagitarius_Arrow_Casted = False
              • Trigger - Turn off (This trigger)
              • Trigger - Turn off Sagitarius Arrow Target DIES <gen>
              • Trigger - Turn off Sagitarius Arrow Casted True <gen>
            • Else - Actions
              • Unit - Kill Sagitarius_Arrow_Dummy
              • Set Sagitarius_Arrow_Casted = False
              • Trigger - Turn off (This trigger)
              • Trigger - Turn off Sagitarius Arrow Target DIES <gen>
              • Trigger - Turn off Sagitarius Arrow Casted True <gen>
      • Custom script: call RemoveLocation(udg_Location3[62])
      • Custom script: call RemoveLocation(udg_Location3[63])
i guess this one does not leak

i have two forces that i use constantly all over the game... if i destroy this variable "AthenaPlayerGroup" with this "call DestroyForce(udg_AthenaPlayerGroup)"

will i be able to use the variable again?

for IE:

  • real spawn units
    • Events
    • Conditions
    • Actions
      • Trigger - Turn off (This trigger)
      • Wait 1.50 seconds
      • Set Location[9] = (Center of Athenas Select Unit Spawn <gen>)
      • Set Location[10] = (Center of Demons Zombies Spawn <gen>)
      • Player Group - Pick every player in AthenaPlayerGroup and do (If (((Picked player) slot status) Equal to Is playing) then do (Unit - Create 1 Divine Spirit for (Picked player) at Location[9] facing Default building facing degrees) else do (Do nothing)) <<<
      • Player Group - Pick every player in HadesPlayersGroup and do (If (((Picked player) slot status) Equal to Is playing) then do (Unit - Create 1 Aflicted Soul for (Picked player) at Location[10] facing Default building facing degrees) else do (Do nothing)) <<<
      • Custom script: call RemoveLocation(udg_Location[9])
      • Custom script: call RemoveLocation(udg_Location[10])
      • Unit - Create 1 Creeps Reviver (Map - Dummy Unit) for Neutral Hostile at (Center of Dummy asassin respawn <gen>) facing Default building facing degrees
      • Unit - Make (Last created unit) Invulnerable
      • Set Assasin_Dummy = (Last created unit)
      • Custom script: call DestroyForce(udg_AthenaPlayerGroup) <<<
      • Custom script: call DestroyForce(udg_HadesPlayersGroup) <<<
      • Custom script: call DestroyTrigger(GetTriggeringTrigger())

if i do this... will i be able to use AthenaPlayerGroup again in another trigger? i know the variable is not destroyed... i mean... the info stored on it... i need it several times later
 
Last edited:
Level 13
Joined
Nov 22, 2006
Messages
1,260
Leak in the first trigger:

  • ((Region centered at (Position of Gemini Kanon 0049 <gen>) with size (900.00, 900.00)) contains (Triggering unit)) Not equal to True
You need to use it as an if/then/else instead of using it as a condition, that's the only way (in GUI) you'll be able to put that generated region in a variable and destroy it afterwards (like you said).

The second trigger leaks here:

  • Unit - Move Sagitarius_Arrow_Dummy instantly to (Location3[62] offset by 30.00 towards (Angle from Location3[62] to Location3[63]) degrees)
Projected locations also leak. For that you need two location variables, one which will hold the original location and the second one which will hold the projected version of the original one (then you need to destroy both of them).

You won't be able to use AthenaPlayerGroup after you destroy it. You could either reproduce it or (since you would use it multiple times) don't destroy it at all, or you can destroy it after the last time you used it.

Note: Some handles that are created once and that same instance is used over and over again, they don't have to be destroyed since it is only a single leak and it won't matter at all. It's those periodic leaks you should worry about (most commonly spells, triggers with a periodic timer event etc.).
 
Level 11
Joined
Dec 31, 2007
Messages
780
Thx a lot silvenon for such quick replays ^^



EDIT: now... so that i can go to sleep happy

  • Sagitarius Arrow Movement
    • Events
      • Time - Every 0.04 seconds of game time
    • Conditions
    • Actions
      • Set Location3[62] = (Position of Sagitarius_Arrow_Dummy)
      • Set Location3[63] = (Position of Sagitarius_Arrow_Targ)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Distance between Location3[62] and Location3[63]) Greater than or equal to 40.00
        • Then - Actions
          • Set Location3[65] = (Location3[62] offset by 30.00 towards (Angle from Location3[62] to Location3[63]) degrees) <<<
          • Unit - Move Sagitarius_Arrow_Dummy instantly to Location3[65] <<<
          • If (((Current flying height of Sagitarius_Arrow_Dummy) Less than or equal to 300.00) and ((Distance between Location3[62] and Location3[63]) Greater than or equal to 2000.00)) then do (Animation - Change Sagitarius_Arrow_Dummy flying height to ((Current flying height of Sagitarius_Arrow_Dummy) + 100.00) at 200.00) else do (Do nothing)
          • If (((Current flying height of Sagitarius_Arrow_Dummy) Greater than or equal to 200.00) and ((Distance between Location3[62] and Location3[63]) Less than 2000.00)) then do (Animation - Change Sagitarius_Arrow_Dummy flying height to ((Current flying height of Sagitarius_Arrow_Dummy) - 100.00) at 200.00) else do (Do nothing)
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Sagitarius_Arrow_Targ is in Spell_Imunity_Group) Not equal to True) and (((Sagitarius_Arrow_Targ is Magic Immune) Not equal to True) and ((Sagitarius_Arrow_Targ is in SleepingGroup) Not equal to True))
            • Then - Actions
              • Unit - Grant shared vision of Sagitarius_Arrow_Targ to (Owner of Sagitarius_Arrow_Dummy)
              • Unit - Order Sagitarius_Arrow_Dummy to Stop
              • Unit - Order Sagitarius_Arrow_Dummy to Human Mountain King - Storm Bolt Sagitarius_Arrow_Targ
              • Wait until (Sagitarius_Arrow_Casted Equal to True), checking every 0.10 seconds
              • Unit - Kill Sagitarius_Arrow_Dummy
              • Unit - Remove Sagitarius_Arrow_Dummy from the game
              • Unit - Deny shared vision of Sagitarius_Arrow_Targ to (Owner of Sagitarius_Arrow_Dummy)
              • Set Sagitarius_Arrow_Casted = False
              • Trigger - Turn off (This trigger)
              • Trigger - Turn off Sagitarius Arrow Target DIES <gen>
              • Trigger - Turn off Sagitarius Arrow Casted True <gen>
            • Else - Actions
              • Unit - Kill Sagitarius_Arrow_Dummy
              • Set Sagitarius_Arrow_Casted = False
              • Trigger - Turn off (This trigger)
              • Trigger - Turn off Sagitarius Arrow Target DIES <gen>
              • Trigger - Turn off Sagitarius Arrow Casted True <gen>
      • Custom script: call RemoveLocation(udg_Location3[62])
      • Custom script: call RemoveLocation(udg_Location3[63])
      • Custom script: call RemoveLocation(udg_Location3[65]) <<<
 
Last edited:
Level 13
Joined
Nov 22, 2006
Messages
1,260
No leaks, good job! :)

This is not related to leaks, but I just want to help you code more efficiently. What's this:

  • Unit - Order Sagitarius_Arrow_Dummy to Human Mountain King - Storm Bolt Sagitarius_Arrow_Targ
  • Wait until (Sagitarius_Arrow_Casted Equal to True), checking every 0.10 seconds
What is Sagitarius_Arrow_Casted? Wait until condition is a really crappy action, I suggest you don't use it. Also, when killing dummy units (or any units in general) with Unit - Kill unit, it apparently leaked a bit for some people, so it is safer (and easier) to use expiration timers, then you don't have to worry about waiting for the dummy caster to finish casting, you can just make the expiration timer expire in like 1.5 seconds. That is enough for any unit to finish casting.
 
Level 11
Joined
Dec 31, 2007
Messages
780
well... this skill is an arrow that flyes throu the sky until it reaches the tartget and casts storm bolt... i wanted to make the trigger the way you say (without wait for condition) but i had some problems... because i move the arrow with the trigger you may see above... and sometimes it died without casting... cos the target moves further than 40... this thing use to hapen when the unit runs away from the arrow... and is a very common thing in an AoS map... so... for it not to bugg i did it that way...

i have a trigger that is "unit starts the effect of an ability" "ability being cast = arrow dummy skill(storm bolt)" "set sagitarius arrow casted == true" (i dont have my map here but is that basically)

to check it out see here


According to the "kill unit" thing... some time ago.. i didnt know abot... kill unit leaks, region leaks, offset leaks and how to turn off one shot triggers... now that i know all that i gotta make a whole check out in my map for all triggers and fix things like those...

Thx a lot for your assistance ^^

EDIT: Btw ... maybe we can keep talking there so that we dont screw this useful topic
 
Last edited:
Level 11
Joined
Dec 31, 2007
Messages
780
New issue (not trying to double post)

Distance between points leaks? it is a real value... should i set it to a variable? or leave it as "Distance between point1 and point2 blabla"
"destroy point1""destroy point2"

Idea: region leaks and turning off triggers should be in ralle's first post (they are not there)
 
Level 7
Joined
Mar 24, 2008
Messages
184
distance between points doesn't leak, as you say, it's a real value, not a Point

Turning off a trigger and destroying it (also destroy the conditions) are two different things, destroying a trigger can't be done in GUI (you need to save conditions in a variable)

Not sure about that, but turning off a trigger doesn't remove it from memory, it's still there, awaiting to be turned on again
 
Level 7
Joined
Mar 24, 2008
Messages
184
Np, but you still have to destroy conditions. Also, if i remember correctly, this post is about leaks you can remove through GUI, not JASS, in GUI you can destroy triggers (i did it on a spell i've made) but conditions for that trigger will stay in memory, and you can't destroy them with GUI
 
Level 12
Joined
Apr 27, 2008
Messages
1,228
Ever since the forum merge.
Because this thread seems to be intended only for GUI and this forum is for everything.
I am not saying I think it should not be sticked. I am just guessing the answer to hawk900's question.
 
Level 11
Joined
Dec 31, 2007
Messages
780
do this leak?

  • Hero - Set (Random unit from (Units owned by Player 1 (Red) matching (((Matching unit) is A Hero) Equal to True))) Hero-level to ((Hero level of (Random unit from (Units owned by Player 1 (Red) matching (((Matching unit) is A Hero) Equal to True)))) + 1), Hide level-up graphics

im asking coz it refers to a unit in a group that doesnt exist
 
Level 19
Joined
Sep 4, 2007
Messages
2,826
do this leak?

  • Hero - Set (Random unit from (Units owned by Player 1 (Red) matching (((Matching unit) is A Hero) Equal to True))) Hero-level to ((Hero level of (Random unit from (Units owned by Player 1 (Red) matching (((Matching unit) is A Hero) Equal to True)))) + 1), Hide level-up graphics

im asking coz it refers to a unit in a group that doesnt exist

You should have made an unit variable which stored the unit. Perhaps you could spice the trigger up a bit?(Ask someone to fix the leak for you)
 
Level 11
Joined
Dec 31, 2007
Messages
780
yes... i read it all... and i wanna say (again) that ralle's first post should have... how to remove region leaks... how to remove one shot triggers (also triggers that are not one shot but that later turn off forever after some time) and (as i read here) sound remove thing in gui should be removed... why? coz GUI sounds are global variables ... and if you destroy them you wont be able to use them again... so... the sound will be played only once... the sounds that should be removed are LOCAL sounds used in JASS coz local sounds doesnt exist in gui... just that


Thx to everybody for the assistance ^^
 
Level 13
Joined
Nov 22, 2006
Messages
1,260
Yeah I think somebody already mentioned the sound thing, but Ralle hasn't seen this thread for about half a year now :p

Region leaks:
  • Set Reg = .....
  • ....
  • Custom script: call RemoveRect(udg_Reg)
Trigger leaks:
  • Custom script: call DestroyTrigger(GetTriggeringTrigger())
(Will destroy This trigger)
  • Custom script: call DestroyTrigger(gg_trg_<trigger name here, with _ instead of spaces>)
(Will destroy some other triggger)

But you already have these somewhere in this thread, not only in the first post.
 
Level 11
Joined
Dec 31, 2007
Messages
780
yes... (except for this one
  • Custom script: call DestroyTrigger(gg_trg_<trigger name here, with _ instead of spaces>)
) its just for people to have them handy and to avoid the task of looking an specific trigger in all of the 23 pages... besides... the sound destroy thing may cause problems (it happened to me :/)
 
Level 13
Joined
Nov 22, 2006
Messages
1,260
Now I have a question which started bugging me about 10 minutes ago. The default value of a unit group in GUI is new group, which is CreateGroup() in JASS, right? So when you create a unit group variable and set it to something, like this:

  • Set Group = (Units in.....)
Won't that leak? Because the CreateGroup() value was lost, in JASS it would be something like this:

JASS:
set udg_Group = CreateGroup
// ...
// ...
set udg_Group = ....
 
Level 12
Joined
Apr 27, 2008
Messages
1,228
I don't think so.
Because it seams that you cannot create a global handle when initializing them.
Example(of what I think):
JASS:
group udg_g = CreateGroup()
Would not create the group.
JASS:
group udg_g
//---------------
function abv takes nothing return nothing
set udg_g=CreateGroup()
endfunction
This would work.
Haven't tested it with groups, but I know it doesn't work with regions(rects) for example, and I think it doesn't work with handles(rest of them) as well. With regions(rects), although the variable window states the default value is new region(rect), in the code doesn't create the region(it is just region udg_region1 = null(Was long ago, can't remeber well).
Even if I am wrong, this is still a one time leak.
 
Top