You can test unnulled variables with this:
library leakTest initializer onInit
globals
private timer t = CreateTimer()
private constant integer LOCS = 500
private integer c = 0
endglobals
private function leaks takes nothing returns nothing
local integer i = LOCS
loop
exitwhen i == 0
set udg_loc = Location(0,0)
call RemoveLocation(udg_loc)
set c = c + 1
set i = i - 1
endloop
set udg_loc = null
endfunction
private function pauseResume takes nothing returns nothing
if ModuloInteger(GetTriggerExecCount(GetTriggeringTrigger()) , 2) == 1 then
call BJDebugMsg("started")
call TimerStart(t, 0.01, true, function leaks)
else
call BJDebugMsg("paused, " + "locs created: " + I2S(c))
call PauseTimer(t)
endif
endfunction
private function onInit takes nothing returns nothing
local trigger t = CreateTrigger()
call TriggerRegisterPlayerEvent(t, Player(0), EVENT_PLAYER_END_CINEMATIC)
call TriggerAddAction(t, function pauseResume)
endfunction
endlibrary
Not nulling it causes memory allocation to increase, very little. Nulling it causes no extra memory allocation.
I believe the same goes for units, if you remove a unit and do not null the variable, it will leak.
It is more difficult to test since craeting units causes variation in memory allocation
library leakTest initializer onInit
globals
private timer t = CreateTimer()
private constant integer dummies = 5
private integer c = 0
endglobals
private function leaks takes nothing returns nothing
//local unit u
local integer i = dummies
loop
exitwhen i == 0
//set u = CreateUnit(Player(0), 'hfoo', 0, 0, 0)
//call UnitApplyTimedLife(u, 1, 0.01)
set udg_u = CreateUnit(Player(0), 'hfoo', 0, 0, 0)
//call UnitApplyTimedLife(udg_u, 1, 0.01)
//call RemoveUnit(u)
call RemoveUnit(udg_u)
//set u = null
set c = c + 1
set i = i - 1
endloop
//set u = null
//set udg_u = null
endfunction
private function pauseResume takes nothing returns nothing
if ModuloInteger(GetTriggerExecCount(GetTriggeringTrigger()) , 2) == 1 then
call BJDebugMsg("started")
call TimerStart(t, 0.001, true, function leaks)
else
call BJDebugMsg("paused, " + "dummes created: " + I2S(c))
call PauseTimer(t)
endif
endfunction
private function onInit takes nothing returns nothing
local trigger t = CreateTrigger()
call TriggerRegisterPlayerEvent(t, Player(0), EVENT_PLAYER_END_CINEMATIC)
call TriggerAddAction(t, function pauseResume)
endfunction
endlibrary