For the following code, if I keep clicking on “Click Me”, I found Lua memory usage keeps increasing.
Later I conclude that timer.cancel() does not release memory right away but until the time out happens (in this case 25 seconds later)
Is this an on-purpose design or I have missed something?
local \_timerHandle local \_button = display.newText("Click Me", 0, 0, native.systemFontBold, 125 ) \_button.x = display.contentWidth\*0.5 \_button.y = display.contentHeight\*0.5 \_button:addEventListener( "tap", function() print("click me is clicked...") if (\_timerHandle ~= nil) then print("cancel previous timer...") timer.cancel(\_timerHandle) \_timerHandle = nil end \_timerHandle = timer.performWithDelay(25000, function() print("timer triggered...") end) end)