Heres some help
~~~I TAKE NO CREDIT LOL i just found this helpful
FULL VERSION
http://ngo.clan.su/forum/10-31-1Leak Tutorial
Made by Clan NgO
You maybe already heard from leaks. Leaks can cause your map to lag, thus a black screen appears after playing your map.
That's because all the leaks which got created have to be cleaned/destroyed. You can fix them easily, even with out JASS experience!
But first off, I'd like to explain what a memory leak in warcraft III is.
What are leaks?
Leaks are handles which are not destroyed and just rest in your memory. It's like in school. You get many information thrown at your head, but you
automaticly forget about everything. So what would happen if we wouldn't have this "forget function" ? -Right! Our heads would overstress and getting slow.
In Warcraft III it's "basicly" the same, having more useless information, which is stored in the memory causes slow calculations.
Note that slow computers are faster affected from memory leaks than faster/better computers.
What leak in Warcraft 3?
Every handle can leak. Handles are:
Quote
# type boolexpr, button, camerafield, camerasetup, destructable, effect, event, fogmodifier, fogstate, force, gamecache, group, image, item itempool, leaderboard, lightning, location, mapvisibility, multiboard, player, quest, rect, sound, region, terraindeformation, texttag, timer, timerdialog, trackable, trigger, ubersplat, unit, widget, weathereffect
Lots of handles! But don't worry, many of this handles you will never have to clear up.
Handles which won't leak, such as Integers, Reals, Booleans & Strings.
How can I clear up those leaks?
Well you have to destroy them with JASS functions. But don't be scared if you are a GUI'er because it's not hard. For every handle type is a different destroy/remove function. Here is the list of the functions:
Now I make some examples to show you how to use them.
In the first example I remove a effect handle:
In the first example I've created a special effect and the action "Destroy (effect)".
But we don't want to destroy the special effect right after it was created! So we save the effect in a special effect variable.
Go to your Variables Editor ( CTRL + B ) and create a special effect with a desired name. In this example we've called it "Name".
After you're done with this, save the effect in your variable. Take a look at this example:
Now to remove it create a new action, which should look like this. Of course you can also put that action into your first trigger:
Now I'm gonna show you an another example. First off, I'll show you what creates the leak.
And after that how to remove it.
Here you can see a typical leak. The unit got created at location of the middle of map. The location did not got removed, thus a leak is born.
But you can easily fix that. First I create in the variables editor location variable. In this example I name the variable Loc.
As you can see, I simply created a variable "Loc" of type location. I set it up to the middle of the map.
After the unit got created I removed it again with the JASS function "RemoveLocation(whichLocation)".
You might ask why I've put a "udg_" before the name of the location. GUI created globals variable got the prefix "udg_" at the beginning of it's name.
"udg" stands for "User Defined Global" with this prefix blizzard just wanted to highlight that it's a global user variable.
There are also variables with other prefixes. For example the variables that Blizzard used in their scripts got the prefix
"bj_" and Sound variables got the prefix "gg_snd" etc.!
With the Jass New Gen Pack you can declare global variables without any prefix.
How do I clean local variables correctly?
Beside to the globals there are the locals. Locals are variables who are just created inside a function and can't used in other functions without any attach functions.
Many guys who use locals think that just destoying the handles of the locals would be all. No it isn't.
Also when you remove this handles they are still in cache cause the locals still got them.
There a easy example:
This is a typical mistake. Many guys don't know that the local "a" and "e" will be still in cache. But with two
easy and short lines of JASS also this leak will be cleaned up.
After you nullified the locals there will be no more leaks. This also should be made with globals if they aren't used anymore.
But remember you don't need to nullify the parameter inside of a function and if you got a function that return something you also have to destroy and to null the locals that arent needed anymore. It should look like this:
How I can avoid the boolexpr leak?
What would be Warcraft 3 without bugs? Right, it wouldn't be Warcraft 3! So there is a bug with the filter function but you can easily avoid it.
Here an example:
How you see I made a null at the boolxpr parameter. Well how you maybe expect, this will leak.
But you can also avoid this easily. Just make a filter function like this:
After you created this filter function you the group function should look like this:
And voilá your function is clean.
How I can avoid leaks of the GameCache?
To clean up stuff inside the gamecache there are several functions:
This are the standart functions to clean up single data.
With this function you clean a whole mission. That means all data you saved with the same missionKey string
will be cleared up. This function is good when you have saved many datas at the same missionKey and you dont want to clear up extra every data.
This function is there to clear up the whole cache.
Hint: You can just initialize 255 gamecaches.
--------------------------------------------------------------------------------
This tutorial were made by:
Hanky
Darkt3mpl3r
Greeting: WaRadius, Toadcop, JonNny and the whole NgO Clan.
Note: The attached file is the tutorial as html file.
Attachments: LeakTutorial.7z(50Kb)
--------------------------------------------------------------------------------