• 🏆 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!

Will a location leak if it's only stored in a variable?

Status
Not open for further replies.
Level 16
Joined
Mar 27, 2011
Messages
1,349
Well it techniquelly hasn't leaked, because the warcraft engine can still remeber "loc1" and hence remove it.

You would also need to remove "loc1" after it has been used to clear up some memory.

  • Custom script: call RemoveLocation (udg_loc1)
Clearing the variable "loc2" shouldn't affect the "loc1" variable.
 
Level 7
Joined
Jan 30, 2011
Messages
267
if he does RemoveLocation(udg_loc2) then he doesnt need to do RemoveLocation(udg_loc1)
loc1 and loc2 are no locations, they just point at a location handle, and that handle has to be removed, so its doesnt matter if u do RemoveLocation(udg_loc2) or RemoveLocation(udg_loc1)
beside that u could null the variables, but that leak is not too bad, cause they are global variables (so they would leak only 1 time if u dont null them)
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,222
locations are objects. They are referenced via handle which is what the variables store. If you remove a location then the handle that pointed to it is no longer valid.

1. set loc1 = some location
2. set loc2 = loc1
3. use loc2
4. clear loc2 with custom script
Both loc1 and loc2 have the handle value of "some location". "some location" has been removed and all resources used by it have been given back to the game to free to the system or be recycled for new objects.

To allow the handle value that was used for "some location" to be recycled you will need to set both loc1 and loc2 to a different location handle such as null or a new/existing location.
 
Status
Not open for further replies.
Top