I’m trying to guess why Profiler finds a mem leak in the following function. Okay I have already done a post (YAL question), but I’m here because there’s something apparently not working with my profiler graph (windows):
Whatever the time param, may mem time line goes always to 3500.
And here is the code
[code]
_W, _H = display.contentWidth, display.contentHeight;
local effectLayer = display.newGroup(); local mRandom = math.random
profiler = require “Profiler”; profiler.startProfiler({time =20000, delay = 1000, mode=3 });
– I change time with no difference on profiler log …
local function doLightnings()
– gundersen code inserted in a Layer :
local lines = display.newGroup()
effectLayer:insert(lines)
local function drawLightning(x1, y1, x2, y2, displace, r, g, b)
if displace < 1 then
–glow around lightning
for i = 1, 2 do
local line = display.newLine(x1, y1, x2, y2)
line:setColor(r, g, b)
line.width = 20 / i
line.alpha = 0.05 * i
lines:insert(line)
end
–bolt itself
local line = display.newLine(x1, y1, x2, y2)
line:setColor(r, g, b)
lines:insert(line)
else
local midx = (x2+x1)*0.5
local midy = (y2+y1)*0.5
midx = midx + (mRandom(0, 1) - 0.5)*displace
midy = midy + (mRandom(0, 1) - 0.5)*displace
drawLightning(x1, y1, midx, midy, displace*0.5, r, g, b)
drawLightning(x2, y2, midx, midy, displace*0.5, r, g, b)
end
end
local function timerDraw(e)
timer.cancel( e.source)
drawLightning( 0, 0, _W, _H,100, 255, 100, 100)
local function timerClear(e)
timer.cancel( e.source )
display.remove(lines)
lines = nil
local lines = display.newGroup()
effectLayer:insert(lines)
end
timer.performWithDelay(mRandom(300), timerClear, 1)
timer.performWithDelay(mRandom(3000), timerDraw, 1)
end
– tmr launch
timer.performWithDelay(mRandom(2000)+1000, timerDraw, 1)
end
doLightnings()
[/code] [import]uid: 9328 topic_id: 17975 reply_id: 76747[/import]