It looks like you're new here. If you want to get involved, click one of these buttons!
function afterDelayPerformFunction(delay, functionToPerform) local timer = Timer.new(delay, 1) timer:addEventListener(Event.TIMER, functionToPerform) timer:start() end function transition() Timer.stopAll() end |
Comments
here's the my test result
1. Using the unofficial function newproxy
2. Using weak tables
@hgvyas123, in your example, you're accessing myTimer as an upvalue. Therefore, it's still accessible and not eligible to GC.
I'm guessing that a paused timer is not eligible for GC (this isn't something I'm concerned with now but I just wanted to make the thread complete).
My apps: http://www.yummyyellow.com
The magic in @Atilim's code is about overriding the __gc function via setmetatable, this is when the GarbageCollector is invoked.
and definitely I am seeing the newProxy function for the first time.
Author of Learn Lua for iOS Game Development from Apress ( http://www.apress.com/9781430246626 )
Cool Vizify Profile at https://www.vizify.com/oz-apps
thnx for the great explanation