Storyboard and Memory Management

I am trying to make sure that I prevent memory leaks in my game. I am using storyboard and in every scene, I have all my display objects in a display group, which I remove and nil out when leaving the scene.

display.remove(screenGroup)  
screenGroup = nil  

Is this the right way to do it?
I have also read that you should do the same for timers,transitions, audio etc, But what about tables. I have lots and lots of tables in my code, some of them are quite big. Can I remove these too and free up some memory?
[import]uid: 208811 topic_id: 37597 reply_id: 67597[/import]

As I understood it, all display objects attached to the scene are disposed of using Corona’s storyboard cleanup routines, so that specific code would be unnecessary. But unattached things like tables, timers, etc. would have to be cleaned up by yourself. [import]uid: 41884 topic_id: 37597 reply_id: 145781[/import]

I created a function and called it killObject which basically helped structur my programming techniques to tie transitions and timers directly to the object. So, when the object goes, anything related to it should go as well. It looks something similar to this:

local function killObject( object ) if object then if object.timer then timer.cancel( object ) end if object.trans then transition.cancel( object ) end display.remove( object ) object = nil print( "Object and related actions successfully removed" ) else print( "Object does not exist" ) end end

And when I create timers or transitions for an object, I make sure it’s assigned as a property of the object:

local logo = display.newImage( "logo.png" ) logo.trans = transition.from( logo, { time = 1000, x = display.contentWidth \* 2, onComplete = function() logo.timer = timer.performWithDelay( 5000, function() killObject( logo ) end ) end } )

[import]uid: 6084 topic_id: 37597 reply_id: 145810[/import]

Thanks for the suggestion, it is a much more clean way of killing objects than what I was thinking of doing. [import]uid: 208811 topic_id: 37597 reply_id: 145813[/import]

As I understood it, all display objects attached to the scene are disposed of using Corona’s storyboard cleanup routines, so that specific code would be unnecessary. But unattached things like tables, timers, etc. would have to be cleaned up by yourself. [import]uid: 41884 topic_id: 37597 reply_id: 145781[/import]

I created a function and called it killObject which basically helped structur my programming techniques to tie transitions and timers directly to the object. So, when the object goes, anything related to it should go as well. It looks something similar to this:

local function killObject( object ) if object then if object.timer then timer.cancel( object ) end if object.trans then transition.cancel( object ) end display.remove( object ) object = nil print( "Object and related actions successfully removed" ) else print( "Object does not exist" ) end end

And when I create timers or transitions for an object, I make sure it’s assigned as a property of the object:

local logo = display.newImage( "logo.png" ) logo.trans = transition.from( logo, { time = 1000, x = display.contentWidth \* 2, onComplete = function() logo.timer = timer.performWithDelay( 5000, function() killObject( logo ) end ) end } )

[import]uid: 6084 topic_id: 37597 reply_id: 145810[/import]

Thanks for the suggestion, it is a much more clean way of killing objects than what I was thinking of doing. [import]uid: 208811 topic_id: 37597 reply_id: 145813[/import]