Simply put, calling transition.pause followed by transition.cancel and then respawning an object causes a memory leak. Am I missing something?
Calling just transition.cancel works great, but I would prefer to give the user the option to reset from a pause menu, for example.
local function draw() local rect1 = display.newRect( display.contentCenterX, display.contentCenterY, 200, 200) rect1.trans = transition.blink( rect1, { time=5000 } ) local function reset() transition.pause(rect1.trans) transition.cancel(rect1.trans ) rect1.trans = nil display.remove(rect1) rect1 = nil draw() end rect1:addEventListener( "tap", reset ) end --INIT: draw() ----- ----- local monitorMem = function() collectgarbage() local memCount = collectgarbage("count") / 1024 if (prevMemCount ~= memCount) then if memCount \< 1.00 then print( "MemUsage: " .. memCount\*1024 .. "KB") prevMemCount = memCount elseif memCount \>= 1.00 then print( "MemUsage: " .. memCount .. "MB") prevMemCount = memCount end end local textMem = system.getInfo( "textureMemoryUsed" ) / 1000000 if (prevTextMem ~= textMem) then if textMem \< 1.00 then print( "TextureMemUsage: " .. textMem\*1024 .. "KB") prevTextMem = textMem elseif textMem \>= 1.00 then print( "TextureMemUsage: " .. textMem .. "MB") prevTextMem = textMem end end end Runtime:addEventListener( "enterFrame", monitorMem )