• Check out the results of the Techtree Contest #19!
  • 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.
  • Create a void inspired texture for Warcraft 3 and enter Hive's 34th Texturing Contest: Void! Click here to enter!
  • The Hive's 22nd Icon Contest: Creep Abilities is now concluded, time to vote for your favourite set of icons! Click here to vote!

Clearing hashtable location leak

Status
Not open for further replies.
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.
 
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.
 
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.
Back
Top