• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[JASS] What functions that will cause memory leak?

Status
Not open for further replies.
Level 13
Joined
Dec 29, 2004
Messages
597
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:
 
Level 7
Joined
May 6, 2005
Messages
390
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:

JASS:
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

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

You should use:

JASS:
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
 
Status
Not open for further replies.
Top