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

Things That Leak

Level 12
Joined
Aug 20, 2007
Messages
866
Custom Scripts/JASS

You need to remove the locations + unit groups (you already knew that)

You code is a bit messed up too

Heres how I'd do it

  • Actions
    • -------- I added a NoLeaks Integer because I heard somewhere that fors A + B leak (not 100% sure bout that one) --------
    • -------- Using the "For" action allows the units to be added to a temporary unit group --------
    • Set Point1 = (Center of Center Large <gen>)
    • -------- This leak keeps from making 6 centers of a region >< --------
    • For each (Integer NoLeaks) from 1 to 6, do (Actions)
      • Loop - Actions
        • Unit - Create 1 Attacker5 for Player 12 (Brown) at Point1 facing Default building facing degrees
        • Unit Group - Add (Last created unit) to UnitGroup1
    • Set Random_Point1 = (Random point in (Playable map area))
    • Unit Group - Order UnitGroup1 to Attack-Move To Random_Point1
    • -------- For your waits, im not really sure what they effect, but you should use a timer --------
    • -------- Or, simply use a periodic event --------
    • -------- I prefer timers over periodic events (you know where they are at with their timing) --------
    • -------- If you are waiting around for a reason (all the other spawns go before this one) --------
    • -------- Then I suggest you have the other ones run this one when they are finished --------
    • Custom script: call DestroyGroup(udg_UnitGroup1)
    • Custom script: call RemoveLocation(udg_Point1)
    • Custom script: call RemoveLocation(udg_Random_Point1)
    • Custom script: set udg_UnitGroup1 = null
    • Custom script: set udg_Point1 = null
    • Custom script: set udg_Random_Point1 = null
    • Custom script: // Here are the actual leak fixes ^^^
    • Custom script: // The global variables (GUI variables) ALWAYS NEED A "udg_" before them
    • Custom script: // in the examples, "udg_" is extremely important then the variable
    • -------- I strongly suggest you learn leaks well, because loops will cause your WC to crash X_x --------
    • Wait 45.00 seconds
    • Set UnitAInt = (UnitAInt + 1)
    • Trigger - Turn on Spawns2 <gen>
    • Trigger - Run Spawns2 <gen> (checking conditions)
    • -------- I don't think your WC can crash from small leaks like this one --------
    • -------- Your crash is probably from another trigger that got f*cked up --------
Don't worry about the length of this, it just looks long as fuck because I put alot of notes in it

Heres the short version

  • Actions
    • Set Point1 = (Center of Center Large <gen>)
    • For each (Integer NoLeaks) from 1 to 6, do (Actions)
      • Loop - Actions
        • Unit - Create 1 Attacker5 for Player 12 (Brown) at Point1 facing Default building facing degrees
        • Unit Group - Add (Last created unit) to UnitGroup1
    • Set Random_Point1 = (Random point in (Playable map area))
    • Unit Group - Order UnitGroup1 to Attack-Move To Random_Point1
    • Custom script: call DestroyGroup(udg_UnitGroup1)
    • Custom script: call RemoveLocation(udg_Point1)
    • Custom script: call RemoveLocation(udg_Random_Point1)
    • Wait 45.00 seconds
    • Set UnitAInt = (UnitAInt + 1)
    • Trigger - Turn on Spawns2 <gen>
    • Trigger - Run Spawns2 <gen> (checking conditions)
 
Level 12
Joined
Aug 20, 2007
Messages
866
Yeah, this won't keep your map from crashing

These leaks are waaaaaaaaaaaaaaaaay too small and occur too slowly

Your map is crashing because there is a trigger that fires periodically and has a bunch of leaks in it

One question

Whats the name of your map???
 
Level 12
Joined
Aug 20, 2007
Messages
866
Show me all the triggers that have a periodic event for the event

There is a little button when you want to reply, it says Wrap
  • tags
  • Use that to make the trigger look like it does in the WE
  • Right-Click the top of the trigger (looks like a page) and click the "Copy as Text" option
  • Paste it here in a reply, and then select it and add the wrap
  • (if you can't do that, just type [TRIGGER]COPY YOUR TEXT HERE[/TRIGGER"])
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,202
Everything in a map should not leak, and that is a fact. As leaks show programming shortcuts which can be easily patched with a few lines of JASS.

Especially for beginners this can be tough, and I understand why but it really is your ultimate aim when making a good map.
 
Everything in a map should not leak, and that is a fact. As leaks show programming shortcuts which can be easily patched with a few lines of JASS.

De-leaking a cinematic that's only gonna run once is incredibly time consuming and tedious. Sure, if you have 50 large cinematics then you should remove the big leaks, but if all you're doing is issuing one move order then it is really just a waste of time.

Besides, say, 200 leaks isn't much at all for a whole map.
 
Level 12
Joined
Aug 20, 2007
Messages
866
Ghostwolf

I'm fairly sure that the crash is from several spawns that happen every 45 secs

The code suggests that it will run in a cycle/loop fashion, with more than one spawn (hence the Spawn2 trigger run)

My guess is that between all the other triggers that leak (probably 12 - 20 of em) that it finally crashes at 11 mins

Yeah, for periodic event leaks it would happen in like, 30 seconds (at least for fast ones, .01 - .40)

Maddawg, learn what JASS is and re-read as many leak fix tutorials as you can

It's much much easier to fix leaks on your own

(You don't need to learn the whole language, just the basics)
 
Level 5
Joined
Jul 11, 2007
Messages
152
Alright I haven't checked back in but I got it I and think the problem was somewhere else. Even with at least 4 periodic triggers running at the same time for the whole map it doesn't crash anymore and I'm working on patching it up so it stays that way. Thanks for the help
 
Level 3
Joined
Dec 26, 2007
Messages
30
  • Events
    • Whatever
  • Conditions
    • Whatever
  • Actions
    • Special Effect - Create an especial efect at (Random point in (Playable map area)) using XXX.mdl
    • Special Effect - Create an especial efect at (Random point in (Playable map area)) using XXX.mdl
    • Special Effect - Create an especial efect at (Random point in (Playable map area)) using XXX.mdl
    • Special Effect - Create an especial efect at (Random point in (Playable map area)) using XXX.mdl
    • Special Effect - Create an especial efect at (Random point in (Playable map area)) using XXX.mdl
    • Special Effect - Create an especial efect at (Random point in (Playable map area)) using XXX.mdl <<<
    • Wait 10 seconds
    • Special Effect - Destroy (Last created especial effect)

Will 'Special Effect - Destroy (Last created special effect)' only destroy the one marked with the '<<<' or all of them?

And can memory leaks cause fatal errors like the one I attached to the post? Or do they just cause lag?

Thanks.
 
Last edited:
Level 12
Joined
Aug 18, 2006
Messages
1,193
the Fatal Error is not a Lag-Issue, but mainly just Wc3 Screwing Up. I had a abusable fatal error in my map(or maybe still have, since i havent attached the updated map :D) that occured when you did a special Teleport after casting a Chain Lightning(Obviously a Trigger Based Teleport). So if you get any Abusable Fatal Errors on your map, you should take note on when or where it is happening and just fix some triggers regarding the Fatal Error.
 
  • Events
    • Whatever
  • Conditions
    • Whatever
  • Actions
    • Special Effect - Create an especial efect at (Random point in (Playable map area)) using XXX.mdl
    • Special Effect - Create an especial efect at (Random point in (Playable map area)) using XXX.mdl
    • Special Effect - Create an especial efect at (Random point in (Playable map area)) using XXX.mdl
    • Special Effect - Create an especial efect at (Random point in (Playable map area)) using XXX.mdl
    • Special Effect - Create an especial efect at (Random point in (Playable map area)) using XXX.mdl
    • Special Effect - Create an especial efect at (Random point in (Playable map area)) using XXX.mdl <<<
    • Wait 10 seconds
    • Special Effect - Destroy (Last created especial effect)

Will 'Special Effect - Destroy (Last created special effect)' only destroy the one marked with the '<<<' or all of them?

And can memory leaks cause fatal errors like the one I attached to the post? Or do they just cause lag?

Thanks.

  • Special Effect - Create an especial effect at (Random point in (Playable map area)) using XXX.mdl
  • Special Effect - Destroy (Last created especial effect)
This works better, and the SFX animation gets played once then gets cleaned up. Flamestrike doesn't seem to like this, so you'll have to use a 0.01 second wait (if you're using flamestrike) before destroying it. Still, the model won't be removed until after the flamestrike effect is finished playing.
 
Level 11
Joined
Aug 25, 2006
Messages
971
How many hundreds of times have I explained that a wait can't wait less then approx .29

So if you tell it to wait .01 it'll wait .29
 
Level 17
Joined
Jun 17, 2007
Messages
1,433
  • Special Effect - Create an especial effect at (Random point in (Playable map area)) using XXX.mdl
  • Special Effect - Destroy (Last created especial effect)
This works better, and the SFX animation gets played once then gets cleaned up. Flamestrike doesn't seem to like this, so you'll have to use a 0.01 second wait (if you're using flamestrike) before destroying it. Still, the model won't be removed until after the flamestrike effect is finished playing.
Using waits in GetLastCreatedX() will remove its MUI.
 
How many hundreds of times have I explained that a wait can't wait less then approx .29

So if you tell it to wait .01 it'll wait .29
NO WAI

No duh. I just wanted to avoid that whole discussion about the minimum wait being 0.27 or 0.29 or whatever, but it seems I can't escape it.
Using waits in GetLastCreatedX() will remove its MUI.

Which is why it's best to use flamestrike as little as possible ;P
 
Level 3
Joined
Dec 15, 2007
Messages
44
Okay, I'm very confused about this whole "leak" topic but I'm trying to understand.

From what I've read it looks like I should redo a trigger I have working on my map, but I need some clarification. First, here's the trigger:



  • Events
    • Time - Every 35.00 seconds of game time
  • Conditions
  • Actions
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • (Magic Academy 0067 <gen> is alive) Equal to True
    • Then - Actions
      • Unit - Create 1 Demon Warlock for Player 1 (Red) at (Center of Left Hell Temple <gen>) facing 180.00 degrees
    • Else - Actions
      • Unit - Create 1 Fel Warlock for Player 1 (Red) at (Center of Left Hell Temple <gen>) facing 180.00 degrees
Does this leak??

If so should I rework it like this:

  • Events
    • Time - Every 35.00 seconds of game time
  • Conditions
  • Actions
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • (Magic Academy 0067 <gen> is alive) Equal to True
    • Then - Actions
      • Set loc = (Center of Left Hell Temple <gen>)
      • Unit - Create 1 Demon Warlock for Player 1 (Red) at loc facing 180.00 degrees
      • Custom script: call RemoveLocation( udg_loc )
    • Else - Actions
      • Set loc = (Center of Left Hell Temple <gen>)
      • Unit - Create 1 Fel Warlock for Player 1 (Red) at loc facing 180.00 degrees
      • Custom script: call RemoveLocation( udg_loc )

I also need to know if I need to have multiple variables for location if I'm going to need to do this multiple times at once. The spawning works like dota creep spawning. Am I going to need a different loc variable (ex. loc1, loc2, loc3, etc) for each spawn point or can it be quickly rewritten on each individual trigger by itself using only one variable? Anyone getting me? Pleeeaaase help, I really want to understand this leak business better.
 
The first one leaks, the second one does not.

I also need to know if I need to have multiple variables for location if I'm going to need to do this multiple times at once. The spawning works like dota creep spawning.

One location variable is all you need unless you're using more than one point in one function. For example:

  • Set TempPoint = center of region 1 <gen>
  • Unit - Create 1 Footman at (TempPoint) facing...
  • Set TempPoint2 = (TempPoint) offset by 256 towards 90 degrees
  • Unit - Create 1 Footman at (TempPoint2) facing...
  • Custom script: call RemoveLocation(udg_TempPoint)
  • Custom script: call RemoveLocation(udg_TempPoint2)
 
Level 3
Joined
Dec 15, 2007
Messages
44
Okay, I think I understand, but just to double check:

If I have multiple of these triggers running at the same time, I won't need multiple variables? Only one? It can be used in all the triggers and won't mess up function?
 
Level 13
Joined
Nov 20, 2006
Messages
553
The first one leaks, the second one does not.



One location variable is all you need unless you're using more than one point in one function. For example:

  • Set TempPoint = center of region 1 <gen>
  • Unit - Create 1 Footman at (TempPoint) facing...
  • Set TempPoint2 = (TempPoint) offset by 256 towards 90 degrees
  • Unit - Create 1 Footman at (TempPoint2) facing...
  • Custom script: call RemoveLocation(udg_TempPoint)
  • Custom script: call RemoveLocation(udg_TempPoint2)

how bout this? is this good?
  • Set TempPoint = center of region 1 <gen>
  • Unit - Create 1 Footman at (TempPoint) facing...
  • Set TempPoint = (TempPoint) offset by 256 towards 90 degrees
  • Unit - Create 1 Footman at (TempPoint2) facing...
  • Custom script: call RemoveLocation(udg_TempPoint)
 
No it won't. You're just updating a variable. Set X = X + 1 works perfectly fine.

how bout this? is this good?
  • Set TempPoint = center of region 1 <gen>
  • Unit - Create 1 Footman at (TempPoint) facing...
  • Set TempPoint = (TempPoint) offset by 256 towards 90 degrees
  • Unit - Create 1 Footman at (TempPoint2) facing...
  • Custom script: call RemoveLocation(udg_TempPoint)

Change the Unit - Create 1 Footman at (TempPoint2) facing... to Unit - Create 1 Footman at (TempPoint) facing....
 
Level 23
Joined
Jul 18, 2004
Messages
1,862
They say you canot teach an old dog new tricks- and reading through this thread and the tutorials it linked to, I'm almost thinking they are right. My head is swirling with this information... I almost think I aint using the right brainhalf for it. I'm the artistic type, not a programmer.

Nevertheless, I need my map cleaned up and will begin the obviously rigorous process of rewriting my many GUI triggers to stop memory leaks from happening. The work will be long and painful, but I'm sure it'll be worth it.

Even though I've read through this thread, I still have a few questions. Some details of memory leaks still escape my comprehension- mostly due to use of terminology that doesn't quite 'click' with me. Shameful, I must admit.

First question;
If I create a dummy unit in a specific location, and that dummy unit dies because I give it a 3 second expiration timer, does it leak? Should the dummy unit be removed entirely, or does it's timed death stop the memory from leaking?

Second;
Spawned special effects that dont have a "stand" animation- so animations that only play once and then disappear (say, the monsoon graphic for example), do they leak? Should they be removed, even though there isnt visually anything 'left' afer their single animation has played once?

More questions will be added as I work through my map. I hope you guys can help me... and are patient enough with my seemingly stupid questions; this just aint my thing. :p
 
Level 13
Joined
Nov 22, 2006
Messages
1,260
First question;
If I create a dummy unit in a specific location, and that dummy unit dies because I give it a 3 second expiration timer, does it leak? Should the dummy unit be removed entirely, or does it's timed death stop the memory from leaking?

It doesn't leak, trust me. That's why expiration timers are best for killing units.

Spawned special effects that dont have a "stand" animation- so animations that only play once and then disappear (say, the monsoon graphic for example), do they leak? Should they be removed, even though there isnt visually anything 'left' afer their single animation has played once?

Yes, it does leak. After the effect is played, it is still there taking memory. With those no-animation effects you can create them and destroy them right after that, the animation will still play (flame strike is an exception). So you can do something like this:

  • Actions
    • Special effect - Create a special effect at blabla using <monsoon>
    • Destroy (Last created special effect)

This way the effect will still play normally and you won't have to worry about leaks.

Think of finished special effects as locations, after they are played, if not cleaned, they just stay there. They are not visible, but they take a bit of memory, like locations.

I hoped that helped a bit.

More questions will be added as I work through my map. I hope you guys can help me... and are patient enough with my seemingly stupid questions; this just aint my thing. :p

You can always ask me anything about leaks, it's my specialty :)
 
Level 23
Joined
Jul 18, 2004
Messages
1,862
Thank you sofar!

A few more questions, some just double-checking "am I doin' it rite?" though.

All my triggers that run once, like initialization and "when 3 seconds has passed", now end with
  • call DestroyTrigger(GetTriggeringTrigger())
This is correct and helps, right?


Replacing all
  • Unit - A unit enters (Entire Map)
with
  • Unit - A unit enters (Playable map area)
, does this really help?


Also adding
  • set bj_wantDestroyGroup = true
to all triggers that have "Pick every unit in unit group.." or "Pick every player in player group..", is this correct?

Or will this malfunction in a trigger such as
  • Unit Group - Pick every unit in (Units owned by Player 7 (Green) of type |cFF00FF00Great Cat Beast|r (Green) (Hunting Pack)) and do (Actions)
    • Loop - Actions
      • Unit - Remove Aura of Courage (Radiant, Great Cat Beast) from (Picked unit)
      • Unit - Remove Bestial Strength (Caller of the Claw, Great Cat Beast) from (Picked unit)
Since "picked unit" is called upon here twice, once to remove the Aura, and once to remove the Bestial Strength?
 
Last edited:
Level 13
Joined
Nov 22, 2006
Messages
1,260
This is correct and helps, right?

Yes, but it helps just a little bit, it's really unnoticeable.

does this really help?

Yes, since Entire Map is a function and Playable Map Area is a variable. And Entire Map leaks, since it's not cleaned (afaik).

....to all triggers that have "Pick every unit in unit group.." or "Pick every player in player group..", is this correct?

That only works for unit groups. You should do that before each "Pick every unit in unit group".

Since "picked unit" is called upon here twice, once to remove the Aura, and once to remove the Bestial Strength?

It won't malfunction, it's right.
 
Level 22
Joined
Feb 26, 2008
Messages
891
Not really. As far as I know, global variables never need to be nulled.
However, if you have a local handle variable (unit, player, etc., but not integer or real), then you have to null that variable in addition to using a DestroyGroup or RemovePoint, if appropriate.
 
Level 19
Joined
Aug 24, 2007
Messages
2,888
Btw GroupEnumUnitsEtc(blablablabal,null<-filter) leaks too
Suggestion:function GroupEnumUnitsRemove takes same things with groupenumunits
groupenumunits
destroy filter
endfunction

Or use a variable
set FilterVar = Filter( a function that returns true)
and use it inside
... Whatever
 
Level 22
Joined
Feb 26, 2008
Messages
891
> the destruction of location is not DestroyLocation nor RemovePoint, it's RemoveLocation

Wow. Right you are. Can't believe I put RemovePoint. I use RemoveLocation all the time....

Some others:

DestroyForce (Player Group)
DestroyEffect (Special Effect)
DestroyTextTag (Not 100%, but I think it's Floating Text)

If I remember correctly, only handles or widgets (widgets just extend handles) need to be nulled. These are things like timers, units, game caches, etc.
But it might not be all of them.... I don't claim to be a JASS expert. :grin:
 
Level 20
Joined
Apr 22, 2007
Messages
1,960
Need_O2 said:
destroy filter
You should never destroy filters, even local. This is because filters always return constant values, as in, if you create two boolexpr locals pointing towards the same function, they're handle indexes will be the same. Another way to understand this is like... boolexpr kind of work like strings in Warcraft III: they're recyclable. If the boolexpr of a function has already been declared, a new handle does not need to be allocated.

@Ghan_04
Here's a list of all of the _useful_ destruction functions:
JASS:
native RemoveLocation           takes location whichLocation returns nothing
native RemoveRect               takes rect whichRect returns nothing
native RemoveRegion             takes region whichRegion returns nothing
//*>native          RemoveUnit          takes unit whichUnit returns nothing
// Shouldn't be used, use this instead:
call ShowUnit( whichUnit, false)
call KillUnit( whichUnit )
//*<
native DestroyEffect                takes effect whichEffect returns nothing
native DestroyForce             takes force whichForce returns nothing
native DestroyGroup                         takes group whichGroup returns nothing
native DestroyImage                 takes image whichImage returns nothing // Ya never know :P
native DestroyItemPool          takes itempool whichItemPool returns nothing
native DestroyLeaderboard               takes leaderboard lb returns nothing
native DestroyLightning             takes lightning whichBolt returns boolean
native DestroyMultiboard                takes multiboard lb returns nothing
native DestroyQuest         takes quest whichQuest returns nothing // Never actually used this one...
native DestroyTextTag               takes texttag t returns nothing
native DestroyTimer         takes timer whichTimer returns nothing // Should avoid this and use a timer recycling system instead.
native DestroyTimerDialog               takes timerdialog whichDialog returns nothing
native DestroyTrigger   takes trigger whichTrigger returns nothing
native DestroyUbersplat             takes ubersplat whichSplat returns nothing // lol
native DestroyUnitPool          takes unitpool whichPool returns nothing
native DialogDestroy                takes dialog whichDialog returns nothing
The other ones, like RemovePlayer, are useless because players always return the same values ( Player(1) will always return the same value, and thus the handle index won't grow and you won't be leaking memory ).
 
Top