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

[JASS] problem fixing leaks

Status
Not open for further replies.
Level 10
Joined
Apr 9, 2004
Messages
502
SetUnitPositionLocFacingBJ( udg_Sentinel[1], PolarProjectionBJ(GetUnitLoc(gg_unit_U000_0051), 60.00, ( GetUnitFacing(gg_unit_U000_0051) - 135.00 )), ( GetUnitFacing(gg_unit_U000_0051) + 180.00 ) )

that's most of it i missed a bit of the begining the "call_ function or something like that (i'm not very experienced in JASS) but i want to be able to remove the position based off of something like that.

Or is there an easier way to clean up locations that i only use once?
 
Level 7
Joined
May 6, 2005
Messages
390
PolarProjectionBJ returns a loction which you HAVE to store in a variable and so do GetUnitLoc. You HAVE to store them in a variable, then use them, and then remove them.. Like this:

JASS:
function SomeFunc takes nothing returns nothing
    local location l = GetUnitLoc(gg_unit_U000_0051)
    local location p = PolarProjectionBJ(l, 60.00, GetUnitFacing(gg_unit_U000_0051) - 135)
    call SetUnitPositionLocFacingBJ(udg_Sentinel[1], p, GetUnitFacing(gg_unit_U000_0051)+180)
    call RemoveLocation(l) // removes the location sp it won't leak
    set l = null // nullyfies the var, so it doesn't leak
    call RemoveLocation(p)
    set p = null
endfunction

You don't really have to use paranthesis in this function.


~Blade
 
Level 11
Joined
Jul 20, 2004
Messages
2,760
Polar Projection is the most leaky stuff. And I'll tell you why by giving the worst leaking example:

PolarProjectionBJ( GetUnitLoc(cast), DistanceBetweenPoints(GetUnitLoc(cast), GetUnitLoc(targ)), AngleBetweenPoints(GetUnitLoc(cast), GetUnitLoc(targ))

Why is it leaky? PolarProjection itself produes leak. GetUnitLoc(cast) produces leak. GetUnitLoc(targ) produces leak. To avoid all the leaks, you need to add the custom code: Remove(PolarProjection). But unfortunately in this case, you will refer to the GetUnitLoc(targ) and GetUnitLoc(cast) ONCE AGAIN. Sooo... Remove these too, but only once you removed the polar projection. Got it by here? Hope so...

Ok, forcefully moving an unit while you remove the polar projection, position, etc. is leakless. But if you forget to remove only one such position you will realize that in the end it will leak, by freezing your computer slowly.

~Daelin
 
Status
Not open for further replies.
Top