Hi
I’ve got a question about object destruction/garbage collection/memory leaks etc.
I’ve got a function below that simply rings a bell after a given interval, using Kyle Coburn’s stopwatch class (https://developer.coronalabs.com/code/stopwatch-timing-class - thanks Kyle)
Below is the gist of it. My question is this: each time the function is called presumably a new stopwatch object is created. Is the old one destroyed? I’m thinking yes but just wanted to be sure. If not, do I need to explicitly destroy it myself? Also, does that runtime event listener have to be explicitly removed before the function is called the 2nd and subsequent times?
thanks,
David
keepingTime = function() timerText = display.newEmbossedText("",display.contentWidth \* .6, display.contentHeight \* .1, app\_font,font\_size) countDown = stopwatch.new(bell\_interval) local function onFrame(event) timerText:setText(countDown:toRemainingString()) if (countDown:toRemainingString() == "00:00") then countDown:addTime(bell\_interval) play\_bell() end end Runtime:addEventListener( "enterFrame", onFrame ) end