Hi,
I am using the director class for a couple of test games. Both suffer from the same issue of memory usage going up and up regardless of what I do.
While playing a level the memory usage is stable. No weird changes and things work as expected.
I have a cleanup function that clears all all the timers and listener events and anything else that I can find. I have a button that takes the player back to the level selection screen and the last thing that it it does is report the system memory.
If I re-choose the level and then exit again the system memory use will be around 3kb to 4kb more. If I exit then go back again, once again the memory will be a further 3 to 4 kb more.
The following code is what is being called before going back to the level select screen.
Any tips on what I might be missing?
I basically just want the entire level and all objects gone but something still seems to be in memory and not being cleared.
Thanks
Mike R
local function cleanup()
timer:cancel(createIt)
background:removeEventListener( “touch”,createIt)
Runtime:removeEventListener(“enterFrame”,checkIt)
Runtime:removeEventListener(“collision”,pinIt)
_G.loadObjectGroup:removeSelf()
textGroup:removeSelf()
savedGroup:removeSelf()
createIt = nil
background = nil
_G.loadObjectGroup = nil
textGroup = nil
savedGroup = nil
allIts = nil
collectgarbage(“collect”)
print (sprite )
end
local function backToLevelList(event)
gameActive = false
physics.pause()
cleanup()
physics.stop()
exitLevel:removeEventListener(“touch”,backToLevelList)
exitLevel = nil
levels = nil
print("System Memory : " … collectgarbage(“count”))
director:changeScene(“levelSelect”,“fade”,true)
end [import]uid: 9950 topic_id: 5754 reply_id: 305754[/import]