Warcraft III resources & community, 2003–2006 · archived

What functions that will cause memory leak?

4 posts
#1

What functions that will cause memory leak?

I'm noob with JASS, so can somebody tell me what function that will cause memory leak if i don't assign it on variable?

I just know for:

- GetTriggerUnit
- GetUnitLoc (or anything that returns location)
- GetLastCreatedEffect

Yeah.. just that, and maybe i have wrong. :?

Hmm.. i think this section should have a sticky for what function that will cause leak. :idea: That's very useful for a JASS noob like me. :lol:
#2
Agreed, stickies could be nice to help people not familiar..

You should store the location in a locl and when you don't need the location longer remove it and nullify the variable.. Like this:

function Jass takes nothing returns nothing
    local location l = GetSpellTargetLoc()
    //actions using the loc
    call RemoveLocation(l)
    set l = null
endfunction


As far as I know GetTriggerUnit doesn't leak, but if you're using it a lot of times within a function, store it in a variable anyway, thats easier..

GetLastCreatedEffect is dumb and should very seldom be used in Jass... Instead of

function Hey takes nothing returns nothing
    local location l = GetSpellTargetLoc()
    local effect e
    call AddSpecialEffectLoc("somePath", l)
    set e = GetLastCreatedEffect()
...


You should use:

function Hello takes nothing returns nothing
    local location l = GetSpellTargetLoc()
    local effect e = AddSpecialEffectLoc("somePath", l)
...


Since all natives that adds special effects returns the effects thats the easiest way..


Because of we haven't got any Jass section nor forum mods I am at The Jass Vault for Jass purposes...

Hopefully that helped you :D (the scripts not that I'm at The Jass Vault)..

Blade
#3
Thanks Blade.dk thats really help.
#4
I'm always glad to help people :D ..