• 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] 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?
 
Level 2
Joined
May 31, 2007
Messages
20
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.
 
Level 40
Joined
Dec 14, 2005
Messages
10,532
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
 
Level 2
Joined
Oct 9, 2006
Messages
15
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.
Top