- Joined
- Feb 4, 2009
- Messages
- 1,314
My pc ran the following code from 13:10 to 17:40
Memory load of wc3 at start: 98.200 K
..and at the end: 98.880 K
Number of created local unit variables: 500.000.000
My pc had a cpu load of 20% while running this code btw so it is unlikely that anyone will ever make more local unit variables in any game
I used GetEnumUnit() instead of setting the local variable to a global variable just in case that it would somehow not work correctly
This should make sure the units are different enough though
there were roughly 100 units in the map, 2 of them heros
all in all I don't think that not nulling local variables can cause any trouble except with H2I/I2H which is not used any more
if someone has an idea why to null local variables please tell me
Memory load of wc3 at start: 98.200 K
..and at the end: 98.880 K
Number of created local unit variables: 500.000.000
My pc had a cpu load of 20% while running this code btw so it is unlikely that anyone will ever make more local unit variables in any game
I used GetEnumUnit() instead of setting the local variable to a global variable just in case that it would somehow not work correctly
This should make sure the units are different enough though
there were roughly 100 units in the map, 2 of them heros
all in all I don't think that not nulling local variables can cause any trouble except with H2I/I2H which is not used any more
if someone has an idea why to null local variables please tell me
JASS:
globals
integer i = 0//count local handles
endglobals
function leak takes nothing returns nothing
local unit u = GetEnumUnit()
if u != null then//to make sure that there is no bug
set i = i + 1
endif
//no "set u = null" :P
endfunction
function leakLoop takes nothing returns nothing
call SetPlayerState(Player(0), PLAYER_STATE_RESOURCE_GOLD, i)//so we actually see that it works but since goldlimit is at 1 million I made a debug msg which displays I2S(i) when pressing esc
call ForGroup(udg_g, function leak)
endfunction
//===========================================================================
function InitTrig_Leak takes nothing returns nothing
local trigger t = CreateTrigger()
call TriggerRegisterTimerEvent(t, 0.0025, true)
call TriggerAddAction(t, function leakLoop)
endfunction