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

Data Leak

Status
Not open for further replies.
Level 33
Joined
Mar 27, 2008
Messages
8,035
If I have 2 variable location, loc1 and loc2 and I do it like this;
set udg_loc1 = udg_loc2, if I want to remove leak, do I have to remove both variable value or just the source (which in this case, loc2 being the source) ?

If a source is destroyed, then udg_loc1 has nothing to hold any longer, meaning that loc1 does not leak, right ?

But if I destroy loc1, will loc2 still leak ?
Because loc1 = loc2, any of them destroy, it will be affected, right ?

So, it is sufficient to only destroy one of them, is it ?
 
Level 12
Joined
Sep 11, 2011
Messages
1,176
If I have 2 variable location, loc1 and loc2 and I do it like this;
set udg_loc1 = udg_loc2, if I want to remove leak, do I have to remove both variable value or just the source (which in this case, loc2 being the source) ?

If a source is destroyed, then udg_loc1 has nothing to hold any longer, meaning that loc1 does not leak, right ?

But if I destroy loc1, will loc2 still leak ?
Because loc1 = loc2, any of them destroy, it will be affected, right ?

So, it is sufficient to only destroy one of them, is it ?

nope. if you set loc2 = (any regions) and loc1 = loc2.. then you remove loc1, loc1 wouldn't leak but loc2 would still be (any regions) that is leak.. so, you should remove both of them :)
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
But... if LocA holds the LocationHandle and LocB stores the value that's saved in LocA, when you remove LocB, LocA would still have the number of the LocationHandle stored in it.

LocA = 10
LocB = LocA

Remove LocB -->

LocA = 10
LocB = null


... or not?
 
Level 26
Joined
Aug 18, 2009
Messages
4,097
@Spartipilo: Do you refer to integers or locations now?

Integers are primitive. They do not point to another area in memory where the data is stored but rather represent the data themselves. Therefore, they have no Destroy-function and are completely independent.

Locations are handles. The object is somewhere stored by wc3 and you can have multiple and different variables that reference the same memory position of it.

locA = Location(0,0)
locB = locA

Both variables will point to the same object.

RemoveLocation(locB)

The object locB points to will be destroyed. locA and locB still refer to the same memory position and of course, locA will also only find a destroyed object when you ask it for its value.

Now, the object is (almost) gotten rid of but variables also reserve memory. You cannot customize their deallocation process though, that's managed by wc3. Maybe you can imagine hashtable data as variables, there you can actually remove entries via functions but for real wc3 variables, it's automatically done. Global variables are static, they are not destroyed, local variables are deallocated when a function call terminates. What you can do though is to nullify local handle (agent) variables before they die. That is because handle (agent) objects are not fully released until they lose all references that once pointed to them --> all variables, hashtable entries etc. should be off the object. Since you cannot create new global variables and you will likely recycle them, it is negligible for them but local variables are always new ones per function call and Blizzard has blundered it to automatically deregister dying local variables from their former objects --> the object cannot be fully released anymore because there are still references you have no access to anymore.
 
A simple trigger would be more than enough to close this thread...
  • Untitled Trigger 001
    • Events
      • Time - Elapsed game time is 0.00 seconds
    • Conditions
    • Actions
      • Set L1 = (Center of RegBig <gen>)
      • Set L2 = L1
      • Unit - Create 1 Footman for Player 1 (Red) at L1 facing Default building facing degrees
      • Unit - Create 1 Footman for Player 1 (Red) at L2 facing Default building facing degrees
      • Custom script: call RemoveLocation(udg_L2)
      • Unit - Create 1 Footman for Player 1 (Red) at L1 facing Default building facing degrees
 
Level 23
Joined
Apr 16, 2012
Messages
4,041
waterknight, you have true except:
if you dont null global variable it is still considered a pointer to object(if not "elementary"(thats how I call them)) the handle id wont recycle so it is kind of leaking still
correct me please if Im wrong sice I didnt test it myself
 
Level 26
Joined
Aug 18, 2009
Messages
4,097
Global variables persist throughout the game and are responsive, so they are not considered as a leak. The object id is not freed before all references are gone, yes, but global variables are usually reused and they are limited.

Well, some other very tiny leak with object variables was reported some years ago, which I cannot confirm nor is it worth the effort.
 
Status
Not open for further replies.
Top