Clean-up question

Just to clarify things for me:

If I have a table called “Blah” which contains 140.345.123 nested tables and objects, and I want to get rid of ALL of them, I just need to set Blah to “nil”, which automatically deletes all the billion nested tables, variables, sub-tables, variables of sub-tables etc. etc. inside of “Blah”, right? In other words, if I set the “root” object (in this case “Blah”) to nil, ALL nested things within will be marked for Garbage Collection, too (as long as there is no other reference to them anywhere else).

  • Is this also true for Display objects (like Images, Shapes etc.) stored within “Blah”? Or do I have to remove them explicitly with Blah.myImage:removeSelf() before setting “Blah” to nil?
    [import]uid: 9644 topic_id: 2691 reply_id: 302691[/import]

I think the LUA side will be cleaned up, but not the engine side, the objects them self. But I could be wrong here. [import]uid: 5712 topic_id: 2691 reply_id: 7939[/import]

Yes, if you have this:

BLA = { lots of LUA only stuff }

Then this:

BLA = nil

Will mark all the stuff in BLA and BLA to be collected at some point in the future.

However, this is bad:

BLA = { lots of stuff and display.newImage() objects, sound files, other corona objects }

BLA = nil – Mem leak on those display objects!

The LUA objects in bla will be cleaned up, but the display objects will still be allocated on corona’s side without a way to access it anymore. (well… not totally true, as you could traverse the STAGE display object… but I wouldnt do that to try and find something)

[import]uid: 8541 topic_id: 2691 reply_id: 7946[/import]

EDIT:

Thanks, sanchan, that was what I thought. So I can treat LUA objects like a chain. All objects below a "nil"ed chain element will be discarded then, too -except Corona elements like display objects, images, sounds etc. [import]uid: 9644 topic_id: 2691 reply_id: 7947[/import]