HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Leaks Leaks And More Leaks! Bla

01-12-2005, 10:33 PM#1
Mjukland
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
Vexorian
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
Mjukland
Quote:
Originally Posted by Lord Vexorian
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.

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
Vexorian
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
Mjukland
Quote:
Originally Posted by Lord Vexorian
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

the momory usage does'nt go back... test the function yourself and you will se.
01-12-2005, 11:11 PM#6
Ryude
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
Mjukland
Quote:
Originally Posted by Ryude
That function does not leak, I use it in several functions and the usage is consistant regardless of how many times I call it.

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
Ryude
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
Mjukland
Quote:
Originally Posted by Ryude
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

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
Mjukland
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
Ryude
http://www.battle.net/forums/war3/th...s&t=131503&p=1

Quote:
12. Re: Unknown Editor Bugs | 6/16/2004 10:11:14 AM GMTDT
Quote this post Reply to this post
I have found memory leak issues with common.j code.
GroupEnumUnitsInRangeOfLoc(g, whichLocation, radius, filter)

If you use null for the filter (which seems to be common practice in alot of the blizzard.j triggers that call it) it creates a large memory leak. Making a filter function (even if it always returns true) helps to reduce the leak alot. I will also check other similar functions. I believe they have the same problem.

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
endfunction

Code:
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>
After this was done in a minute, as in the code you see above, the memory usage wasn't growed at all. So I can see how it possible should leak and if it really does then it's minimal.
01-13-2005, 08:42 PM#13
curi
Events
Time - Every 0.00 seconds of game time

Does that work? What does it do?
01-14-2005, 12:37 AM#14
Mjukland
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
Ryude
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).