EdgeOfChaos
E
EdgeOfChaos
So, I decided to use the function from this thread to discover whether I had memory leaks: http://www.hiveworkshop.com/forums/triggers-scripts-269/things-leak-35124/
Specifically, this is what I wrote.
This works fine, and it shows the number of handles I have. The confusing thing was when it said that the number of handles were increasing by thousands every second - i.e. thousands of memory leaks. I had been coding carefully, so I went through and disabled all the triggers until I found what caused it.
This caused the leaks:
I messed around with it for a while and found that if I removed the DestroyGroup call, it would no longer leak, like this:
But from my knowledge of JASS, I would have expected the first one would not leak, and the second one would. It turned out to be the opposite when I coded it. I'm wondering why, or if there is some problem with the code that showed the handle count in the first place.
Specifically, this is what I wrote.
JASS:
library Debug initializer onInit
globals
private boolean debugOn = true
private boolean handleCountOn = true
private timer t
private constant real PERIOD = 1.
endglobals
private function handleCount takes nothing returns nothing
local location L = Location(0,0)
call BJDebugMsg(I2S(GetHandleId(L)-0x100000))
call RemoveLocation(L)
set L = null
endfunction
private function onInit takes nothing returns nothing
if(debugOn and handleCountOn)then
set t = CreateTimer()
call TimerStart(t,PERIOD,true,function handleCount)
endif
endfunction
endlibrary
This works fine, and it shows the number of handles I have. The confusing thing was when it said that the number of handles were increasing by thousands every second - i.e. thousands of memory leaks. I had been coding carefully, so I went through and disabled all the triggers until I found what caused it.
This caused the leaks:
JASS:
private function bSleep takes nothing returns nothing
local group g = CreateGroup()
call GroupEnumUnitsInRect(g,GetPlayableMapRect(),Filter(function sleepFilter))
call DestroyGroup(g)
set g = null
endfunction
JASS:
private function bSleep takes nothing returns nothing
local group g = CreateGroup()
call GroupEnumUnitsInRect(g,GetPlayableMapRect(),Filter(function sleepFilter))
set g = null
endfunction