Hello. This might be a silly question, but I just want to make sure I’m doing it right to avoid having any memory leaks. Let’s say I have a table nested inside another table. Would the following method work to clean up both tables?
local group = display.newGroup() local textGroup = display.newGroup() textGroup.text = {} for i=1, 10 do textGroup.text[i] = display.newText('Text', 0, i\*20, native.systemFont) textGroup:insert(textGroup.text[i]) end group.text = display.newText('Display Group', 0, 0, native.systemFont) group:insert(group.text) group:insert(textGroup) for i=1, group.numChildren do group:remove(1) end
I know the code is a little messy, but it’s just for example purposes.
As you can see, one group has another group inside of it. This nested textGroup has several display objects. When I remove textGroup, am I also removing all display objects?
Thanks.