| 01-12-2005, 10:33 PM | #1 |
the line in red... it leaks... its a native function... WHAT TO DO!???? EDIT : Ok, found out that the location leaks, the filter would also if I had one. a new location is created and not destroyed, how do you fix something like that in a native function? Code:
function GetUnitsInRangeOfLocMatchingTest takes real radius, location whichLocation, boolexpr filter returns nothing
local group g = CreateGroup()
[color=Red] call GroupEnumUnitsInRangeOfLoc(g, whichLocation, radius, filter)[/color]
call DestroyBoolExpr(filter)
call GroupClear(g)
call DestroyGroup(g)
set g = null
endfunction
function TESTLEAK takes nothing returns nothing
local location l = null
set l = GetUnitLoc(udg_Hero[1])
call GetUnitsInRangeOfLocMatchingTest(100,l,null)
call RemoveLocation(l)
set l = null
endfunction
//===========================================================================
function InitTrig_TESt takes nothing returns nothing
set gg_trg_TESt = CreateTrigger( )
call TriggerRegisterTimerEventPeriodic( gg_trg_TESt, 0.01 )
call TriggerAddAction( gg_trg_TESt, function TESTLEAK )
endfunction
|
| 01-12-2005, 10:41 PM | #2 |
I made my own test about that native, and it doesn't leak, it just takes more time to clean the memory it uses some how, keep an eye on your test map, it will eventually get to a constant. |
| 01-12-2005, 10:50 PM | #3 | |
Quote:
found out that the location leaks, the filter would also if I had one. it doesn't clean the memory. It have to be somekind of leak. call GetUnitsInRangeOfLocMatchingTest(100,l,null) <--- leaks call GetUnitsInRangeOfLocMatchingTest(100,null,null) <--- does'nt leak |
| 01-12-2005, 10:52 PM | #4 |
Second won't leak because it doesn't do anything. Really wait sometime and you will see the memory usage of your test map going to some constant, and if you make the calling of the function stop, it would go back to a low value |
| 01-12-2005, 10:57 PM | #5 | |
Quote:
the momory usage does'nt go back... test the function yourself and you will se. |
| 01-12-2005, 11:11 PM | #6 |
That function does not leak, I use it in several functions and the usage is consistant regardless of how many times I call it. |
| 01-12-2005, 11:25 PM | #7 | |
Quote:
Then why is my memroyusage increaed by roughly 25kb/s when I have this trigger running? well.. the memory usage increases by 4kb for some seconds, and then it jumps up 100kb, increases by 4kb for some time and then jumps 100kb again. And no, the memoryusage is not lowered after I turn it of, it just stays at the same value. Code:
function TESTLEAK takes nothing returns nothing
call GroupEnumUnitsInRangeOfLoc(udg_LEAKGroup,udg_LEAKPoint , 200, null)
endfunction
//===========================================================================
function InitTrig_TESt takes nothing returns nothing
set gg_trg_TESt = CreateTrigger( )
call TriggerRegisterTimerEventPeriodic( gg_trg_TESt, 0.01 )
call TriggerAddAction( gg_trg_TESt, function TESTLEAK )
endfunction |
| 01-13-2005, 01:56 AM | #8 |
Clean the location and group. Code:
local group g local location l call GroupEnumUnitsInRangeOfLoc(g,l,500,null) RemoveLocation(l) DestroyGroup(g) set g=null set l=null |
| 01-13-2005, 03:10 AM | #9 | |
Quote:
Ok, I've solved my problem, you were right, the native did'nt leak if cleaned right. also I used set group1 = group2, instead of using the function add group to group, this caused a major leak. Thanks for all help. |
| 01-13-2005, 04:00 AM | #10 |
BaH, no wait. I made a couple of mistakes... look at this trigger.. it leaks. Code:
function Trig_TESTFUNCTION_Actions takes nothing returns nothing
local location l = null
local group g = CreateGroup()
local boolexpr b = null
set l = GetUnitLoc(udg_Hero[1])
call GroupEnumUnitsInRangeOfLoc(g, l, 100, b)
call DestroyGroup(g)
set g = null
call RemoveLocation(l)
set l = null
endfunction
//===========================================================================
function InitTrig_TESTFUNCTION takes nothing returns nothing
set gg_trg_TESTFUNCTION = CreateTrigger( )
call TriggerRegisterTimerEventPeriodic( gg_trg_TESTFUNCTION, 0.01 )
call TriggerAddAction( gg_trg_TESTFUNCTION, function Trig_TESTFUNCTION_Actions )
endfunction
|
| 01-13-2005, 07:10 AM | #11 | |
http://www.battle.net/forums/war3/th...s&t=131503&p=1 Quote:
Well there we have it. |
| 01-13-2005, 07:08 PM | #12 |
Guest | Code:
function Trig_LeakFunc_Actions takes nothing returns nothing
local location l= GetUnitLoc(gg_unit_hkni_0000)
local group g = CreateGroup()
call GroupEnumUnitsInRangeOfLoc(g, l, 1000, null)
call GroupClear(g)
call DestroyGroup(g)
call RemoveLocation(l)
set l = null
set g = null
endfunctionCode:
TestLeakTrig1
Events
Time - Every 0.00 seconds of game time
Conditions
Actions
Custom script: call Trig_LeakFunc_Actions()Code:
TestLeakTrig2
Events
Time - Elapsed game time is 60.00 seconds
Conditions
Actions
Trigger - Turn off TestLeakTrig1<gen> |
| 01-13-2005, 08:42 PM | #13 |
Events Time - Every 0.00 seconds of game time Does that work? What does it do? |
| 01-14-2005, 12:37 AM | #14 |
Time - Every 0.00 seconds of game time Yeah, does that work? I used every 0.01 sec, and the memoryusage increased alot, I'll test the boolexpr = null thing that Ryude mention, though I belive this did'nt leak : call GroupEnumUnitsInRangeOfLoc(g, null, 1000, null) if that is the case, Im not sure, don't realy remember now, and I have'nt got wc3 on this computer so I can't test. Then if that does'nt leak, would it not be the location that leaked ? or would it still be the boolexpr thing Ryude mention, but if u have'nt got a loc the boolexpr might never be checked, so it could still be that... this needs further testing... |
| 01-14-2005, 01:58 AM | #15 |
It has to be the boolexpr, there is nothing else that leaks in the code. I opened up the common.j and I cannot find anything else that would leak in there. Another option is to create your own GroupEnumUnitsInRangeOfUnit(g,whichUnit,radius). |
