Composer freeing up nested groups.

Is Composer supposed to work like this ?

If I create and promptly destroy a scene like this:

local composer = require( "composer" ) composer.loadScene("demoscene") composer.removeScene("demoscene")

it’s supposed to free up the resources used by the scene, I think. If I look at the view member of the scene, it has indeed been set to nil by this. 

If I take the standard scene template and add this to create()

   local newGroup = display.newGroup()    newGroup:insert(display.newRect(0,0,100,100))    sceneGroup:insert(newGroup)    \_G.group = newGroup    \_G.scene = self

This creates a group, sticks a rectangle in it, and inserts it into the scene group (self.view)

If I print out _G.scene.view after removing it, then it prints nil as you would expect - the view is removed as part of Composers Garbage collection.

However, if you print _G.group.numChildren it prints 1, implying that the rectangle is still in the group, printing the references shows it is the same child.

The composer.removeScene documentation says _ “If shouldRecycle is omitted or set to false (default), the scene will be removed entirely, including its scene object” _but it apparently isn’t ?

Any ideas ? Do you basically have to clean up groups in destroy ?

Maybe I’m just mixing up how Lua cleans up things, but by creating a second reference to the group, doesn’t that block garbage collection? (as the data still exists, just owned by a global instead of the local)

One might think the best way to check if the recycle happens is to just use a memory printout runtime (like performance meter, I think there’s a version floating around the code repository) and record Lua memory both (a) after creating the group and (b) after disposing of the scene?

The thing I have a problem with is the garbage collection that runs in Composer. It’s supposed to ‘Corona GC’ - e.g. free up display resources and it seems like it doesn’t :slight_smile:

It’s not a major problem - fonts can be created and deleted on a per scene basis, or scenes can be marked so they can’t be reclaimed.

Maybe I’m just mixing up how Lua cleans up things, but by creating a second reference to the group, doesn’t that block garbage collection? (as the data still exists, just owned by a global instead of the local)

One might think the best way to check if the recycle happens is to just use a memory printout runtime (like performance meter, I think there’s a version floating around the code repository) and record Lua memory both (a) after creating the group and (b) after disposing of the scene?

The thing I have a problem with is the garbage collection that runs in Composer. It’s supposed to ‘Corona GC’ - e.g. free up display resources and it seems like it doesn’t :slight_smile:

It’s not a major problem - fonts can be created and deleted on a per scene basis, or scenes can be marked so they can’t be reclaimed.