[JASS] fixing memory leaks

Status
Not open for further replies.
Level 7
Joined
Feb 15, 2005
Messages
183
ok, so my map is leaking and im not sure why, i was very careful about destroying and nulling my locals. I do have one quick question that one of you might be able to answer.

If I have a local location, can I use that same location and keep reassigning new locations to it until the very end where i destroy and nullify it? or does it get lost in memory if I don't null the previous value before i reassign a new one?
 
Well, i'm not 100% sure, so anyone might correct me if i'm wrong.
If you use any native/function returning a location it'll leak, because you overwrite the old handle with a new one, but if you MOVE the location it won't leak, due you still use the old handle.
So don't create a new location just move the old one or destroy it before assigning a new position of the location.
 
You don't have to null it every time, but you have to destroy it every time..

Eg.

JASS:
local location x = Location(0,0)
set x = Location(0,0)
call RemoveLocation(x)
set x = null

leaks

JASS:
local location x = Location(0,0)
call RemoveLocation(x)
set x = Location(0,0)
call RemoveLocation(x)
set x = null

doesn't leak
 
hmm... just looked at this thread here..

i have a problem with my map too. its the same bug as in Tides of Blood.
whenever i want to play any other map than mine (after i played mine) i get a server split and leave the game.

is there a simple command to unload every variable or whatever.. to clear the memory or so?

some kinda "if i leave the game, clear everything".
 
Status
Not open for further replies.
Back
Top