Do you have to manually call :removeSelf() on all widgets?

Hi all,

I remember reading somewhere in the Corona docs that for all widgets you have to manually call removeSelf() and nil out the widget var like this:

local button function scene:createScene( event ) local group = self.view button = widget.newButton( { your init params here } ) group:insert(button) end function scene:destroyScene( event ) if button then button:removeSelf() button = nil end end

But what if you scope your widget variable to inside the createScene function like this:

function scene:createScene( event ) local group = self.view local button = widget.newButton( { your init params here } ) group:insert(button) end function scene:destroyScene( event ) -- don't need to clean up the widget? end

Will the resources automatically be released now?

Hi @spacewolf,

This should work fine, since you’re inserting the button into the self.view in both cases.

Brent

Thanks Brent! I wanted to be sure I wasn’t creating some kind of memory leak or something :slight_smile:

Hi @spacewolf,

This should work fine, since you’re inserting the button into the self.view in both cases.

Brent

Thanks Brent! I wanted to be sure I wasn’t creating some kind of memory leak or something :slight_smile: