| 01-28-2007, 08:52 PM | #1 |
Hey! I hope someone here can help me with finding the memory leaks in these functions:/ always thought i could handle em but after 20min of gametime, (100x casts of the spell that's using the headerfunc) most pc almost crash and the performance sucks. I really cannot find anything wrong:/. Think the functions are quite easy to understand! Thx, and gn8 :D PS: "PolarProjectionX" and "PolarProjectionY" are just a way to realize the usual PolarProjectionBJ but without using locations - reals are quite a way better for the performance as most people say JASS:function MoveMissileChild takes nothing returns nothing local timer t = GetExpiredTimer() local unit missile = GetHandleUnit(t, "missile") local real speed = GetHandleReal(t, "speed") local real angle = GetHandleReal(t, "angle") local real x = GetUnitX(missile) local real y = GetUnitY(missile) local real xnew = PolarProjectionX(x, speed, angle) local real ynew = PolarProjectionY(y, speed, angle) call SetUnitPosition( missile, xnew , ynew ) if IsUnitDeadBJ(missile) then call PauseTimer(t) call SetHandleHandle(t, "missile", null) call SetHandleReal(t, "speed", 0) call SetHandleReal(t, "angle", 0) call FlushHandleLocals(t) call DestroyTimer(t) endif set missile = null set t = null endfunction function MoveMissile takes unit missile, real speed, real angle returns nothing local timer t = CreateTimer() call SetHandleHandle(t, "missile", missile) call SetHandleReal(t, "speed", speed) call SetHandleReal(t, "angle", angle) call TimerStart(t, 0.01, true, function MoveMissileChild) set t = null set missile = null endfunction |
| 01-28-2007, 09:01 PM | #2 |
You didn't your reals (Correct me if Im wrong) for first and you nulled missle twice -Av3n |
| 01-28-2007, 09:05 PM | #3 |
This isnt the cause of your lag (unless the unit never dies and the timers keep running) JASS:
call SetHandleHandle(t, "missile", null)
call SetHandleReal(t, "speed", 0)
call SetHandleReal(t, "angle", 0)
|
| 01-29-2007, 08:27 AM | #4 |
JASS:
call SetHandleHandle(t, "missile", null)
call SetHandleReal(t, "speed", 0)
call SetHandleReal(t, "angle", 0)
isnt needed... jeah i know :( but i've written it in order to test if there is any improvement, but you're right nothings going better.. @av3n: nullifying twice wont cause a leak :P; and reals wont cause leaks, i've always read! but i can test it.. on wc3jass.com the "holy" kattana hasnt found any leaks, too. but when i am creating a missile dummy-unit with a 2sek expiration timer (~200 actions) every casting will cause a 100K leak...thats too much, as many spells shall use this headerfunction...mb spells with 9 missiles on each cast (multiple arrows etc) and these leaks will accumulate to a horrible memory waste -.- |
| 01-29-2007, 09:52 AM | #5 |
Try using SetUnitX and SetUnitY instead of SetUnitPosition |
| 01-29-2007, 10:12 AM | #6 |
Doesnt work, too...about 1000k memory loose. ill post all function used...really dont find anything responsible for that...seems like kattanas handlevars suck extremly :( JASS:function Trig_Mehrfachschuss_Actions takes nothing returns nothing local unit caster = GetSpellAbilityUnit() local integer level = GetUnitAbilityLevelSwapped('A008', caster) local integer index = 0 local integer indexend = 5 + level local unit missile local real speed = 10 local real winkel local real kegelweite = 60.00 local real damage = 25 * (level + 1) local real detect = 50 local location temp1 = GetUnitLoc(caster) local location temp2 = GetSpellTargetLoc() local location temp3 local real startwinkel = AngleBetweenPoints(temp1, temp2) loop exitwhen index == indexend set winkel = startwinkel -kegelweite/2 + index*kegelweite /(indexend+1) set temp3 = PolarProjectionBJ( temp1, 120, winkel) call CreateNUnitsAtLoc( 1, 'hfoo', GetOwningPlayer(caster), temp3, winkel ) set missile = GetLastCreatedUnit() call UnitApplyTimedLifeBJ( 1.00, 'BTLF', missile ) call MoveMissile(missile, speed, winkel) //call MissileDamage(missile, caster, detect, 0, damage, 0, false, false, 1,"Objects\\Spawnmodels\\Critters\\Albatross\\CritterBloodAlbatross.mdl" ) set index = index + 1 endloop call RemoveLocation(temp1) call RemoveLocation(temp2) call RemoveLocation(temp3) set caster = null set level = 0 set index = 0 set indexend = 0 set missile = null set speed = 10 set winkel = 0 set kegelweite = 0 set damage = 0 set detect = 0 set temp1 = null set temp2 = null set temp3 = null set startwinkel = 0 endfunction i have even nullifyd reals OO atm the spell is spawning footies ;) Now my actual headerfunctions: JASS:constant function MoveMissileStringSpeed takes nothing returns string return "speed" endfunction constant function MoveMissileStringAngle takes nothing returns string return "angle" endfunction constant function MoveMissileStringMissile takes nothing returns string return "missile" endfunction function PolarProjectionX takes real x, real distance, real angle returns real local real xnew = x + CosBJ(angle) * distance if xnew < GetRectMinX(GetPlayableMapRect()) then return GetRectMinX(GetPlayableMapRect()) return endif if xnew > GetRectMaxX(GetPlayableMapRect()) then return GetRectMaxX(GetPlayableMapRect()) return endif set x = 0 set distance = 0 set angle = 0 return xnew endfunction function PolarProjectionY takes real y, real distance, real angle returns real local real ynew = y + SinBJ(angle) * distance if ynew < GetRectMinY(GetPlayableMapRect()) then return GetRectMinY(GetPlayableMapRect()) return endif if ynew > GetRectMaxY(GetPlayableMapRect()) then return GetRectMaxY(GetPlayableMapRect()) return endif set y = 0 set distance = 0 set angle = 0 return ynew endfunction function MoveMissileChild takes nothing returns nothing local timer t = GetExpiredTimer() local unit missile = GetHandleUnit(t, MoveMissileStringMissile()) local real speed = GetHandleReal(t, MoveMissileStringSpeed()) local real angle = GetHandleReal(t, MoveMissileStringAngle()) local real x = GetUnitX(missile) local real y = GetUnitY(missile) local real xnew = PolarProjectionX(x, speed, angle) local real ynew = PolarProjectionY(y, speed, angle) call SetUnitX( missile, xnew) call SetUnitY( missile, ynew) if IsUnitDeadBJ(missile) then call PauseTimer(t) call SetHandleHandle(t, MoveMissileStringMissile(), null) call SetHandleReal(t, MoveMissileStringSpeed(), 0) call SetHandleReal(t, MoveMissileStringAngle(), 0) call FlushHandleLocals(t) call DestroyTimer(t) endif set missile = null set t = null set speed = 0 set angle = 0 set x = 0 set y = 0 set xnew = 0 set ynew = 0 endfunction function MoveMissile takes unit missile, real speed, real angle returns nothing local timer t = CreateTimer() call SetHandleHandle(t, MoveMissileStringMissile(), missile) call SetHandleReal(t, MoveMissileStringAngle(), angle) call SetHandleReal(t, MoveMissileStringSpeed(), speed) call TimerStart(t, 0.01, true, function MoveMissileChild) set t = null set missile = null set speed = 0 set angle = 0 endfunction |
| 01-29-2007, 10:14 AM | #7 | |
Quote:
it's just btw... haha.. :cool: look at this ! Code:
local location temp3 .... call RemoveLocation(temp3) == Thread Killer Numero Uno ! NEVER use unintialized vars ! (for safety) |
| 01-29-2007, 10:53 AM | #8 |
hmm never heard of a problem like that...but this temp3 loc only occures 9x for each footy/missile spawned...so that cannot be the 1200K leak..and the function Trig_Mehrfachschuss_Actions isnt responisble for the leaks i've debugged them... |
| 01-29-2007, 11:55 AM | #9 |
You people should already be using grimoire's war3err for testing your map. Dancell IT IS the leak, after it crashes the thread it prevents the clean up. |
| 01-29-2007, 01:15 PM | #10 |
Hey thx! Never heard of that problem! Thought a code like that would work properly.. JASS:local location temp set temp = GetUnitLoc( ... ) call RemoveLocation(temp) and wouldnt cause any error..in other forums no one as pointed out that error at any time, therefore i was so surprised. so u guys think the problem istn the headerfunction, but the Trig_Mehrfachschuss_Actions - function? well i have a look at that! |
| 01-29-2007, 01:22 PM | #11 |
dancel - better use coordinates (not locations)... |
| 01-29-2007, 01:30 PM | #12 |
hmm, in my headerfunction i'm working with coordinates..but in that Trig_Mehrfachschuss_Actions i'm creating dummy-units and "CreateNUnitsAtLocFacingBJ" (or so) takes a location and no coordinates! or is there any other function that creates units? |
| 01-29-2007, 01:42 PM | #13 |
dancel - ofc yes ! CreateUnit() it's takes takes player,integer unitid,real x,real y,real facing thats all ! |
| 01-29-2007, 01:53 PM | #14 |
Oh indeed this is what i was looking for! but one problem occures when using that function...GetLastCreatedUnit() doesnt refer to units created via the CreateUnit() function, but i would like to do some actions with those units! any other way to refer to that units? think a unit group would work properly but will cause leaks to? |
| 01-29-2007, 02:08 PM | #15 |
dancel you haven't see the wc3 mapmaker "Brut Force" ;) they rocks ! |
