Can I just get confirmation that including a listener for the ENTER_FRAME event in a class init() method will not prevent the object from being collected if no other references exist? e.g:
function MyClass:init()
self:addEventListener(Event.ENTER_FRAME, self.onEnterFrame, self)endfunction MyClass:onEnterFrame()end
MyClass.new()
Will that instance get collected correctly without first removing the listener.
Yes It was fixed with 2012.08.2. (In release notes, it's mentioned as Bug: Event objects shouldn't store target object internally (late GC of target object))
@john26, I think in that older version it was a genuine leak. The recommendation back then was to ensure that ENTER_FRAME handlers were removed when an object was taken off the stage. Hence, I always used to use ADDED_TO_STAGE and REMOVED_FROM_STAGE handlers to install/remove the ENTER_FRAME handlers (if that makes sense).
Anyway, as @atilim has confirmed the bug has been fixed in the latest download so there should be no need to jump through these hoops now.
Comments
https://github.com/gideros/gideros
https://www.youtube.com/c/JohnBlackburn1975
For example, if you test this code:
best regards
https://github.com/gideros/gideros
https://www.youtube.com/c/JohnBlackburn1975
Anyway, as @atilim has confirmed the bug has been fixed in the latest download so there should be no need to jump through these hoops now.
best regards