• 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.

[General] Leak ?

Status
Not open for further replies.
Level 33
Joined
Mar 27, 2008
Messages
8,035
Will this leak ?
  • Custom script: Set TempLoc = SomePoint
  • -------- DO SOMETHING WITH THE SomePoint --------
  • Custom script: Set TempLoc = SomePoint2
  • -------- DO SOMETHING WITH THE SomePoint2 --------
  • Custom script: Set TempLoc = SomePoint3
  • -------- DO SOMETHING WITH THE SomePoint3 --------
  • Custom script: call RemoveLocation(udg_TempLoc)
Basically, does overwriting Point, causes leak (even though we properly clean it in the end) ?
 
Level 23
Joined
Apr 16, 2012
Messages
4,041
Yes.

This is because variable is only like a bucket, and you fill that bucket with liquids, which are the objects created.

However, when you do something like RemoveLocation, what you basically do is you look into the bucket, and what is currently in the bucket gets removed. But when you assign to the variable some different location, what you do is basically you take the bucket, you say "I dont need this anymore" and you pour the liquid inside the bucket on the ground, and fill it with another. But you cant destroy something that is not in bucket(or hashtable, gamecache).

So if SomePoint and SomePoint2 are created, not just referenced(like loaded from hashtable), then yes, you leak 2 points, because they are still in the memory, but you dont have anyone pointing their finger on them(all variables except real, boolean and integer are basically pointers)
 
Status
Not open for further replies.
Top