Does "GetUnitLoc" and "GetSpellTargetLoc" leak?

Status
Not open for further replies.
Level 22
Joined
Sep 24, 2005
Messages
4,821
They won't if you remove it if it's no longer needed; Reals are better, unless you're manipulating the z axis.
 
Level 11
Joined
Oct 11, 2012
Messages
711
They won't if you remove it if it's no longer needed; Reals are better, unless you're manipulating the z axis.

Thanks, buddy. :)

Any location will leak if it's not removed, so use coordinated as chobibo said.

Also, when using a local location variable (local location l = GetUnitLoc()), it has to be nulled before the function ends.

Got it, thanks.
 
Level 22
Joined
Sep 24, 2005
Messages
4,821
Dude try looking on the common.j (extract it from the mpq), look for all types related to agents, IIRC, all those leak references when not nulled.
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
does
DestroyLocation(LocationVariable) works the same as nullying the variable that holds the Location handle?

I think you have to destroy the location, and then null the variable.
 
Level 20
Joined
Aug 13, 2013
Messages
1,696
Use coordinates because they're much faster than locations, coordinates does not need to remove because they're real.
GetUnitLoc:
Using Locations: Does need to remove.
JASS:
local location MyLoc = GetUnitLoc ( MyUnit )
call RemoveLocation ( MyLoc )
set MyLoc = null
Using Coordinates: Does not need to remove.
JASS:
local real x = GetUnitX ( MyUnit )
local real y = GetUnitY ( MyUnit )
GetSpellTargetLoc:
Using Locations: Does need to remove.
JASS:
local location MyLoc = GetSpellTargetLoc ( )
call RemoveLocation ( MyLoc )
set MyLoc = null
Using Coordinates: Does not need to remove.
JASS:
local real x = GetSpellTargetX ( )
local real y = GetSpellTargetY ( )
 
Level 11
Joined
Oct 11, 2012
Messages
711
Use coordinates because they're much faster than locations, coordinates does not need to remove because they're real.
GetUnitLoc:
Using Locations: Does need to remove.
JASS:
local location MyLoc = GetUnitLoc ( MyUnit )
call RemoveLocation ( MyLoc )
set MyLoc = null
Using Coordinates: Does not need to remove.
JASS:
local real x = GetUnitX ( MyUnit )
local real y = GetUnitY ( MyUnit )
GetSpellTargetLoc:
Using Locations: Does need to remove.
JASS:
local location MyLoc = GetSpellTargetLoc ( )
call RemoveLocation ( MyLoc )
set MyLoc = null
Using Coordinates: Does not need to remove.
JASS:
local real x = GetSpellTargetX ( )
local real y = GetSpellTargetY ( )

Thanks, +Rep
 
Level 11
Joined
Oct 11, 2012
Messages
711
I ran a test, global location nulled -> no memory increase in task manager. Not nulled -> consntant increase of memory consumption.

I created/destroyed at least 100 000 locations.

Are you sure the increase of memory consumption is because of nulling the global locations? I never null such globals and any kind of global... -_-

Edit:
how did you null them? Just like nulling local locations?
 
Status
Not open for further replies.
Top