Discussion in 'World Editor Help Zone' started by aple, Mar 2, 2017.
It would appear so, can anyone confirm this?
function CreateUnitAtLocSaveLast takes player id,integer unitid,location loc,real face returns unit
if (unitid == 'ugol') then
set bj_lastCreatedUnit = CreateBlightedGoldmine(id, GetLocationX(loc), GetLocationY(loc), face)
set bj_lastCreatedUnit = CreateUnitAtLoc(id, unitid, loc, face)
function CreateNUnitsAtLoc takes integer count,integer unitId,player whichPlayer,location loc,real face returns group
set count = count - 1
exitwhen count < 0
call CreateUnitAtLocSaveLast(whichPlayer, unitId, loc, face)
call GroupAddUnit(bj_lastCreatedGroup, bj_lastCreatedUnit)
function CreateNUnitsAtLocFacingLocBJ takes integer count,integer unitId,player whichPlayer,location loc,location lookAt returns group
return CreateNUnitsAtLoc(count, unitId, whichPlayer, loc, AngleBetweenPoints(loc, lookAt))
function AngleBetweenPoints takes location locA,location locB returns real
return bj_RADTODEG * Atan2(GetLocationY(locB) - GetLocationY(locA), GetLocationX(locB) - GetLocationX(locA))
I do not see it leaking a location object internally...
Obviously if you leak the location object you pass to it by not removing the location after the end of its useful life then that location object will leak. But in any case that is not the fault of the create unit action.
CreateUnit, the native. Takes an X, Y, Player ID, and a unit ID. It's none of those. It's not in Blizzard.j or Common.j so that's why I'm asking if anybody knows for sure or not. I'm wondering if internally it's taking that X and Y you feed it and creating a point with it but not actually removing the point afterwords.
It is a native. Chances are what it does with the values have nothing to do with JASS.
I remember testing CreateUnit, monitoring handle IDs and such. The only increase in handle id it causes is the unit itself. The unit created seems to permanently increase memory consumption however I think that is an internal memory leak in WC3 and affects all units ever made (even ones made by structures and summons). The unit memoy leak might also be subject to garbage collection and even have been patched for all I know. However it has no complexity so will not cause lag.
Okay, so any difference I've seen by moving over to CreateUnitAtLoc is a placebo effect then.
CreateUnitAtLoc executes faster as it has to pass 1 less parameter. However for the speed difference to be apparent you will already be creating far too many units per second.
It wasn't necessarily a speed difference I thought I saw, it was a slowdown difference. Something in the code in my map was leaking like hell, and I found what I thought was a point-leak as the CreateUnits was just taking X of mypoint and Y of mypoint. I changed it to CreateUnitAtLoc and fed it my point and destroyed my point afterwords and there was no more noticeable slowdowns. I was already destroying my point before-hand, though, and there was still noticeable slowdowns. I changed it and then there was not.
I'm certain that CreateUnit does not leak a location, just from experience (and because that implementation would make no sense). But if you want to test it - make a test map where you create units and then remove them using both methods, and add the HandleCounter lib to it to count the leaks.
Separate names with a comma.