YAL question

Okay, it’s Yet Another Leak question.

I tried to use from the ‘share code’, the great lightnings effects.
Thx to the really cool Corona Profiler lib, I know that the following code causes a great leak.

I have tried to narrow the issue to a single function. Any help would be welcomed.

[code]
local function doLightnings()

– gundersen code inserted in a Layer :
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

lines = display.newGroup();
effectLayer:insert(lines);
end

timerStash.newTimer = timer.performWithDelay(mRandom(300), timerClear, 1)
timerStash.newTimer = timer.performWithDelay(mRandom(3000), timerDraw, 1)

end

– tmr launch
timerStash.newTimer = timer.performWithDelay(mRandom(2000)+1000, timerDraw, 1)

end
[/code] [import]uid: 9328 topic_id: 19743 reply_id: 319743[/import]

Antheor,
Here is a profiler result for this snippet of code:
http://www.mydevelopersgames.com/site/Profiler/LightningTest/profileTimeline.html

Did you profile long enough to enter the timerClear function? If not then you will probably see a huge numbers of allocation events (due to the new lines) with no matching deallocation events. But appearing from the graph there are no memory leaks, all the troughs of the sawtooth shape go to the same memory.

Thanks,
M.Y. Developers [import]uid: 55057 topic_id: 19743 reply_id: 76790[/import]

Oh, this is a good news.
Sorry I misunderstood Profiler warning “change in memory is 92k”.
I noticed the sawtooth shape, but I had noticed that it was not going back as low as it should have. I was wrong.

Thx for your support. [import]uid: 9328 topic_id: 19743 reply_id: 76893[/import]