I don't think you'll ever have problems with this, the leaks are really small (maybe it even got fixed).
function Trig_Untitled_Trigger_001_Actions takes nothing returns nothing
local group g = CreateGroup()
local unit u
local integer i = 0
call TriggerSleepAction(5.)
loop
call GroupAddUnit(g, CreateUnit(Player(0), 'hpea', GetRandomReal(-10000., 10000), GetRandomReal(-10000., 10000), 270))
set i = i+1
exitwhen i == 1000
endloop
call TriggerSleepAction(10.)
loop
set u = FirstOfGroup(g)
exitwhen u == null
call GroupRemoveUnit(g, u)
call KillUnit(u)
//as well as call RemoveUnit(u)
set u = null
endloop
endfunction
//===========================================================================
function InitTrig_Untitled_Trigger_001 takes nothing returns nothing
set gg_trg_Untitled_Trigger_001 = CreateTrigger( )
call TriggerAddAction( gg_trg_Untitled_Trigger_001, function Trig_Untitled_Trigger_001_Actions )
endfunction
I always set my dummy unit Combat - Death Type: Can't raise, Does not decayDead units are automaticly removed when their decay finishes. There is no need to remove them via triggers unless they cannot decay such as heroes or units specificly set to not decay.
Well, it shouldn't if you remove it via expiration timer? iThink.I always set my dummy unit Combat - Death Type: Can't raise, Does not decay
So, my dummy unit leaks ?
10 hours?!?! Dude... u mad!That is a terrible leak. In my map, all units are created on the initialization. I have a really specific unit recycling system that doesn't allow an unit to get removed from the game (or truly die) so I have this solved. Summoned units are summoned via triggers so that they get recycled as well. However, if you mean to have your map run for an hour, it will not be a problem, mine is aimed at 10 hours at least, and with a lot of combat, the data would build up.
+ 10 hour map must be at least 20 MB...I have played a custom max of 5 hours.
10 hours too crazy.
I have played a custom max of 5 hours.
10 hours too crazy.
hmm....128 mb? When I started empty map it took 98 Mb of my memory
what item data leaks? Im curious
What about nulling global variables ?
Kingz argued with Magtheridon96 about nulling global variables.
Mag said, the action is proven to be good if object compare is large in quantity.
If the object quantity is like 100+-, don't null the global variables (it's pretty pointless).
But if we're making a script that handles object like 1000++, nulling global variables really helps since the game does not need to keep the data (after finish use).
globals
location array l
endglobals
function ABC takes nothing returns nothing
local integer i = 0
call BJDebugMsg("start")
loop
set l[i]=Location(GetRandomReal(-4000, 4000), GetRandomReal(-4000, 4000))
call RemoveLocation(l[i])
set i=i+1
exitwhen i==1000
endloop
endfunction
struct AB extends array
private static method onInit takes nothing returns nothing
local trigger t = CreateTrigger()
call TriggerRegisterTimerEvent(t, 3., true)
call TriggerAddAction(t, function ABC)
endmethod
endstruct
What about nulling global variables ?
Kingz argued with Magtheridon96 about nulling global variables.
Mag said, the action is proven to be good if object compare is large in quantity.
If the object quantity is like 100+-, don't null the global variables (it's pretty pointless).
But if we're making a script that handles object like 1000++, nulling global variables really helps since the game does not need to keep the data (after finish use).
But you still have to null globals (or change their value, that is) if you destroy the object the handle (our variable) is pointing to, just to free up handle stack space.Handle variables hold pointers and other types are very basic data so it barely takes any memory.
How do you test the RAM value speed ?
By the way, can you test with units ?
Locations get removed naturally by RemoveLocation, but Units is different story.
Just set Unit[Array] up to 1000 (create 1000 units in the map).
I don't mention about killing the units.units leaks by default as proven
Which was ?Also, I do what edo suggested.
globals
unit array u
endglobals
function ABC takes nothing returns nothing
local integer i = 0
call BJDebugMsg("start")
loop
set u[i]=gg_unit_hpea_0000
set i=i+1
exitwhen i==1000
endloop
endfunction
struct AB extends array
private static method onInit takes nothing returns nothing
local trigger t = CreateTrigger()
call TriggerRegisterTimerEvent(t, 3., true)
call TriggerAddAction(t, function ABC)
endmethod
endstruct
function init takes nothing returns nothing
set l = Location(500.0, 500.0)
call BJDebugMsg(I2S(GetHandleId(l)))
call RemoveLocation(l)
set l = null
call BJDebugMsg(I2S(GetHandleId(Location(100.0, 200.0))))
endfunction
@HappyTauren,
If nulling variables frees up handle stack space, shouldn't this display same number twice?
JASS:function init takes nothing returns nothing set l = Location(500.0, 500.0) call BJDebugMsg(I2S(GetHandleId(l))) call RemoveLocation(l) set l = null call BJDebugMsg(I2S(GetHandleId(Location(100.0, 200.0)))) endfunction
EDIT: Nevermind, it actually does if I create the second location in another function.
this is getting reallllly off topic, this has nothing to do with dead units leaking anymore
you have point, its impossible to clear unit leaks but its proven that nulling globals is next to useless
function tuturu takes nothing returns nothing
set l = Location(100.0, 200.0)
call BJDebugMsg(I2S(GetHandleId(l)))
endfunction
function init takes nothing returns nothing
call TimerStart(CreateTimer(), 1.00, false, function tuturu)
set l = Location(500.0, 500.0)
call BJDebugMsg(I2S(GetHandleId(l)))
call RemoveLocation(l)
set l = null
endfunction
scope LeakTest initializer Init
globals
private integer count = 0
private integer countrun = 0
private player owner = Player(0)
endglobals
private function Run takes nothing returns nothing
loop
set count = count + 1
exitwhen count > 10
//call RemoveItem(CreateItem('gcel', 0, 0))
call RemoveUnit(CreateUnit(owner, 'hpea', 0, 0, 0))
//call RemoveDestructable(CreateDestructable('LTbs', 0, 0, 0, 1, 1))
endloop
set count = 0
set countrun = countrun + 1
if countrun >= 6000 then
call BJDebugMsg("60000 objects were created, check the memory used now!")
call PauseTimer(GetExpiredTimer())
call DestroyTimer(GetExpiredTimer())
endif
endfunction
private function Init takes nothing returns nothing
call TimerStart(CreateTimer(), 0.01, true, function Run)
endfunction
endscope
globals
location l
endglobals
function ABC takes nothing returns nothing
set l = Location(200., 500.)
call RemoveLocation(l)
set l = Location(100., 150.)
call RemoveLocation(l)
set l = null
endfunction
Apparently, Blizzard isn't changing their "referenced" boolean in whatever map they're using for the variables when you change the value of a global, so it still counts as referenced.
You need to null globals before you change their value just to fix this bug.
I'm only asserting this, I'll see if this is actually true later when I'm not lazy.