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

Clearing hashtable location leak

Status
Not open for further replies.
Level 20
Joined
Jul 6, 2009
Messages
1,885
I just have a small question,is there a way to clean location leaks through hashtables or do i have to set those locations to variables and then clean them.
For example,i save a location with 0 and 1 as arrays and i want to clean that position,what should i write...
  • Custom script: call RemoveLocation(udg_here?)
 
Set them in a variable. If not, the leak won't be gone.
Best way for me is using reals X/Y.
So, you will save the X and Y coordinates of the location. Example:
  • Set Point1 = (Target point of ability being cast)
  • Hashtable - Save (X of Point1) as Key(x) of (Key(Triggering unit)) in Hashtable
  • Hashtable - Save (Y of Point1) as Key(y) of (Key(Triggering unit)) in Hashtable
  • Custom script: call RemoveLocation (udg_Point1)
The loading part (example):
  • Set Real_X = (Load Key(x) of (Key(Triggering unit)) in Hashtable)
  • Set Real_Y = (Load Key(y) of (Key(Triggering unit)) in Hashtable)
  • Custom script: call CreateUnit ('hfoo', GetOwningPlayer(GetTriggerUnit()), udg_Real_X, udg_Real_Y, 0)
And that one doesn't leak at all :)

You can also do that, by converting the stored coordinates into a point:
  • Set Point2 = (Real_X, Real_Y)
  • Custom script: call RemoveLocation (udg_Point2)
It's from Convert coordinates to point. You will remove the leak, without any doubts of whether it leaks or not.
 
Level 13
Joined
Feb 18, 2009
Messages
1,381
I think a point leaks nomatter what, as long as you set up the variable, and if you don't set the variable, then you have used up RAM for no good.
 
Level 13
Joined
Feb 18, 2009
Messages
1,381
But, if you use a Unit Group and instead of using "Set UnitGroup = All units in playable map area" but do "Add Picked unit to UnitGroup" it won't leak.
 
X and Y do not leak, they are simple real values. Points do leak though.
So this:
JASS:
local unit u = GetTriggerUnit()
local real x = GetUnitX (u)
local real y = GetUnitY (u)
call CreateUnit (GetOwningPlayer(u), 'hfoo', x, y, 0)
set u = null
doesn't leak, but the next one does leak:
JASS:
local unit u = GetTriggerUnit()
local location l = GetUnitLoc (u)
 
Status
Not open for further replies.
Top