I used system is this.
------------------------------------------------------------------------------------
function Trig_Spawn_Footmen_Func001Func002001 takes nothing returns boolean
return ( RectContainsUnit(RectFromCenterSizeBJ(GetPlayerStartLocationLoc(GetEnumPlayer()), 384.00, 384.00), GroupPickRandomUnit(GetUnitsOfPlayerAndTypeId(GetEnumPlayer(), 'hbar'))) == true )
endfunction
function Trig_Spawn_Footmen_Func001A takes nothing returns nothing
// Barracks -> Footman
if ( Trig_Spawn_Footmen_Func001Func002001() ) then
call CreateNUnitsAtLoc( 1, 'hfoo', GetEnumPlayer(), GetPlayerStartLocationLoc(GetEnumPlayer()), bj_UNIT_FACING )
else
call DoNothing( )
endif
endfunction
function Trig_Spawn_Footmen_Actions takes nothing returns nothing
call ForForce( GetPlayersAll(), function Trig_Spawn_Footmen_Func001A )
endfunction
//===========================================================================
function InitTrig_Spawn_Footmen takes nothing returns nothing
set gg_trg_Spawn_Footmen = CreateTrigger( )
call TriggerRegisterTimerEventPeriodic( gg_trg_Spawn_Footmen, 8.00 )
call TriggerAddAction( gg_trg_Spawn_Footmen, function Trig_Spawn_Footmen_Actions )
endfunction
--------------------------------------------------------------------------------
is this system have the memory leakage?