correctly removing display groups to avoid memory leaks and dangling pointers.

hi

in my app I have a menu, and then the user goes to the main activity area. I’m using several display groups for the menu part, and several more for the ‘main’ part. The user can go back and forth between menu and main, which involves destroying the active groups each time I leave an area, and then recreating them when I go back.

So right now whenever I go to the main area I have something like this:

mainData.displayGroupTable = {ksDisplayGroup = display.newGroup(),submitDisplayGroup = display.newGroup(), questionDisplayGroup = display.newGroup() }

then when I’m about to leave main to go to the menu, I have

for s,v in pairs (main.displayGroupTable) do     display.remove(main.displayGroupTable[s])     main.displayGroupTable[s] = nil     end

I think this is correct memory management but I just wanted to confirm. Thanks!

Looks right to me.

Rob

thanks!

Looks right to me.

Rob

thanks!