memory leak in ui.lua?

I’m looking through ui.lua to understand exactly what it is doing (very instructive by the way) and I’m confused about if the event listener needs to be removed. I see button:addEventListener( "touch", button ) but no removeEventListener anywhere. Do event listeners automatically get cleaned up along with objects when they are garbage collected?

More generally, how do you get rid of buttons? Do you just call removeSelf on the button like you do with other graphics? [import]uid: 12108 topic_id: 4493 reply_id: 304493[/import]

I’m also wondering about how memory management works with regards transitions. What happens to the memory if I set a movement transition on an object, put a completion function on the transition that calls removeSelf, then immediately nil the reference to the object? I did this with the code below and the movement animation looks great, but I don’t know if the object goes to the garbage collector after this or if I need to somehow clear out the transition object.

function Level:slideOut()  
 transition.to(self, {time = 200, x = -320, onComplete = self})  
end  
function Level:onComplete()  
 self:removeSelf()  
end  

ADDITION:
I posted some sample code in another thread that happens to show what I’m asking about here:
http://developer.anscamobile.com/forum/2010/12/12/finding-objects-parent#comment-14209

I don’t know if the buttons or scene transitions are leaking. [import]uid: 12108 topic_id: 4493 reply_id: 14116[/import]

Can anyone from Ansca help us?

I’m using “ui.lua” with “director” and I’m also wondering about the absence of “removeListeners”.
[import]uid: 6005 topic_id: 4493 reply_id: 26031[/import]

Since starting this thread I’ve learned two important things about the event listeners on buttons. One, removeSelf() does clean up event listeners. Just call removeSelf() on the button and Corona takes care of all the details.

In other words, when I asked “Do event listeners automatically get cleaned up along with objects when they are garbage collected?” the answer is “yes.”

The other important thing is that you can simply call removeEventListener() on a button to deactivate it, because the listener is the button itself. In other words type:

button:removeEventListener("touch", button)  

I manually deactivate my buttons because I routinely want them off but visible (eg. while scenes are transitioning.) [import]uid: 12108 topic_id: 4493 reply_id: 26032[/import]

Thanks for your tips jhocking! [import]uid: 6005 topic_id: 4493 reply_id: 26036[/import]