Intresting.
Does anyone know how severe this purported leak is? If so should I really bother about it?
Yes units do leak. You can see a clear increase in memory usage over time by running a unit create and remove loop with a low period.
Purgeandfire said:When I tested it a month or so ago, the memory seemed to climb a little but after a while it dropped and didn't really go beyond that. But my testing wasn't thorough/documented or anything, so I can't really make any conclusions from that. We just need someone to make a legitimate test and post it in the lab.
function looping takes nothing returns nothing
local integer i = 1
//local unit u
loop
exitwhen i == 0
call RemoveUnit(CreateUnit(Player(15), 'hfoo', 0, 0, 0))
//set u = CreateUnit(Player(15), 'hfoo', 0, 0, 0)
//call UnitApplyTimedLife(u, 1, 0.01)
//call UnitApplyTimedLife(CreateUnit(Player(15), 'hfoo', 0, 0, 0), 1, 0.01)
set udg_k = udg_k + 1
set i = i - 1
//set u = null
endloop
endfunction
function Trig_Untitled_Trigger_001_Actions takes nothing returns nothing
if udg_i == 0 then
set udg_i = 1
call BJDebugMsg("start")
call TimerStart(udg_tmr, 0.01, true, function looping)
else
set udg_i = 0
call BJDebugMsg("stop")
call BJDebugMsg(I2S(udg_k))
call PauseTimer(udg_tmr)
endif
endfunction
//===========================================================================
function InitTrig_Untitled_Trigger_001 takes nothing returns nothing
local unit u
set gg_trg_Untitled_Trigger_001 = CreateTrigger( )
set u = CreateUnit(Player(15), 'hfoo', 0, 0, 0)
call UnitApplyTimedLife(u, 1, 0.01)
call TriggerRegisterPlayerEventEndCinematic( gg_trg_Untitled_Trigger_001, Player(0) )
call TriggerAddAction( gg_trg_Untitled_Trigger_001, function Trig_Untitled_Trigger_001_Actions )
set u = null
endfunction
First 20 000 units -> +3 MB
Next 40 000 units -> +1 MB
Next 37 000 units -> No increase
Next 25 000 units -> +1 MB
Next 18 000 units -> No increase
Next 9 000 units -> No increase
Then I did shorter burts of 1000 units and there was no increase.
What memory were you measuring? Working Set, for example, only shows the memory which is very recently and almost continuously used. Memory leaks only show up on the Working Set if they share pages with non-leaked objects that are in heavy use. Virtual Memory size, on the other hand, shows how much physical address space the process has allocated.
Especially if you are creating units in a loop, you may find entire pages are leaking that fall off the Working Set. Pages not in the Working Set will be paged out more readily than pages in the Working Set of at least 1 process.