• 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] So, nulling handle variables to prevent leaks?

Status
Not open for further replies.
Level 4
Joined
Jun 8, 2004
Messages
66
I've heard more than a few people recently say that you're supposed to null out a handle variable even after you call the destroy function on it in order to prevent leaks.

When did this come about? I had never heard about it few years back when I started mapping, only recently now that I've resumed.

Why would this be required?
 
Level 14
Joined
Nov 20, 2005
Messages
1,156
If the reference count on a handle never falls to 0, then it never gets recycled. This means a leak of a handle index (which is likely more than the 4 byte pointer - 4 bytes is nothing). Anyway, local variables have a bug whereby if at the end of the function the local is still pointing to a variable, it doesn't decrement.

It seems that those set by parameters aren't effected, and it should also be noted that it doesn't matter if you null or not for permament handles, since they will never get recycled anyway (eg: heroes that are always revived, etc).
 
Status
Not open for further replies.
Top