Which variables do you have to set to null to prevent memory leaks?
I had been doing units and groups, but I saw someone else's map set local player variables to null too. Is this necessary?
nulling local variables
Moderator: Cheaters
-
- Senior Member
- Posts: 178
- Joined: February 15th, 2009, 9:08 pm
-
- Forum Staff
- Posts: 811
- Joined: January 1st, 2008, 12:58 am
Re: nulling local variables
Every handle except real / integer should be nulled. Special ones like groups should be DestroyGroup()'d first.
Wanna learn to hack maps? --> Guide
-
- Senior Member
- Posts: 178
- Joined: February 15th, 2009, 9:08 pm
Re: nulling local variables
I guess it's a good thing I don't use local players much then
-
- Forum Staff
- Posts: 829
- Joined: January 28th, 2007, 8:10 pm
- Title: JASS Programmer
- Location: Canada
Re: nulling local variables
storyyeller wrote:I guess it's a good thing I don't use local players much then
I use local players all the time.
Locals are much better as long as you remember to null handles.
-
- Senior Member
- Posts: 178
- Joined: February 15th, 2009, 9:08 pm
Re: nulling local variables
No, what I mean is that I use integers to refer to the player, since even if I used actual player variables, I'd jut have to convert to an integer whenever I wanted to index an array with it anyway
E.g. stuff like this
E.g. stuff like this
Code: Select all
function whatever takes nothing returns nothing
local integer p = GetPlayerId(GetTriggerPlayer())
// do stuff here
endfunction
-
- Forum Staff
- Posts: 829
- Joined: January 28th, 2007, 8:10 pm
- Title: JASS Programmer
- Location: Canada
Re: nulling local variables
Aha, I see. I make a lot of spells and, as you can imagine, I use a lot of unit/player variables.