I’m using the director class, and being VERY careful to remove all objects, timers, transitions, listeners, and everything else once I’m done. But my Lua memory is jumping around a lot. Should it be identical (once I move away from a scene, then return to it)? Texture memory always returns to the same level, that’s just fine.
Here’s the weird behaviour:
CASE 1: If I transition from the mainmenu.lua to my level1.lua, then back and forth a lot, texture memory is perfect (always returns to same level), and Lua memory is the same too.
CASE 2: if I create and destroy many objects repeatedly in level1.lua, then return to mainmenu.lua, the Lua memory goes up a few hundred bytes (texture memory stays the same). Then if I load level1.lua again but don’t create/destroy anything, just exit right away, the Lua memory goes down a bit (but not to the same level).
CASE 3: If I create and destroy many objects in level1.lua, then return to mainmenu.lua, then go back to level1.lua and create/destroy again, then keep repeating that, I can get the Lua memory to increase 2-3kB. But then it jumps back down! Then gradually starts climbing again… but never gets higher than 2-3kB from its initial point.
I noticed the director class (v1.3) demo does the same thing - Lua memory sometimes stays the same, sometimes goes up, keeps going up a few kB, then jumps back down.
Is this normal? I’ve been working for hours to try to clean everything up, but now I’m wondering if that’s even possible…
I’m using this code at the end of the “clean” function for my “level1.lua”:
[lua] – collect garbage
collectgarbage( “collect” )
– print memory usage
local memUsage_str = string.format( “memUsage = %.3f KB”, collectgarbage( “count” ) )
print( memUsage_str )
local texMemUsage_str = string.format( “texMemUsage = %.3f KB”, system.getInfo( “textureMemoryUsed” ) )
print( texMemUsage_str )[/lua]
[import]uid: 49372 topic_id: 9427 reply_id: 309427[/import]