removeSelf() not reducing memory usage?

Help! - what am I doing wrong here?

I have taken the following code out of my application and simplified
As you can see I use the removeSelf on my newly created group however the memory seems to increase despite the objects being removed. - any ideas?


–Console output

Current Mem: 0
Number of children to remove: 1
Removed scene
Current Mem: 21504
Number of children to remove: 1
Removed scene
Current Mem: 26688
Number of children to remove: 1
Removed scene
Current Mem: 31872
Number of children to remove: 1
Removed scene
Current Mem: 37056


–Code main.lua

local ui = require(“ui”)
local scene

function IntialiseScene()

scene = display.newGroup()
local btnTest = ui.newButton{
default = “images/backButton.png”,
over = “images/backButton_over.png”,
text = “scene2”,
emboss = true
}
btnTest.x = 85; btnTest.y = 45
scene:insert(btnTest)

end

function DestroyScene()
if (scene ~= nil) then
if (scene.numChildren ~= nil) then
print ("Number of children to remove: "…scene.numChildren)
scene:removeSelf( )
print “Removed scene”
end
end
end

print ("Current Mem: " … system.getInfo(“textureMemoryUsed”))
IntialiseScene()
DestroyScene()
scene=nil
print ("Current Mem: " … system.getInfo(“textureMemoryUsed”))
IntialiseScene()
DestroyScene()
scene=nil
print ("Current Mem: " … system.getInfo(“textureMemoryUsed”))
IntialiseScene()
DestroyScene()
scene=nil
print ("Current Mem: " … system.getInfo(“textureMemoryUsed”))
IntialiseScene()
DestroyScene()
scene=nil
print ("Current Mem: " … system.getInfo(“textureMemoryUsed”))

thanks,
J [import]uid: 9640 topic_id: 2714 reply_id: 302714[/import]

OK, might have figured it out. This seems to work:

scene:removeSelf( )
collectgarbage(“collect”)

not sure if this is correct use of collectgarbage as I cant find it in the API page?

J [import]uid: 9640 topic_id: 2714 reply_id: 8069[/import]