• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

[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