composer - memory leak testing

Hi,

I have noticed when looking at the composer API that there is no longer a property to print memory usage as there was in storyboard. How should I be testing for memory leaks?

I tried adding the “composer.isDebug = true” property at the beginning of my game.lua file but i am not seeing anything happening in the terminal. does this just mean it is without errors? Or should there be some activity happening in the terminal anyway?

Hi @Ducky,

A pretty standard memory checking function is as follows…

[lua]

local function checkMem()

   collectgarbage(“collect”)

   local memUsage_str = string.format( “MEMORY= %.3f KB”, collectgarbage( “count” ) )

   print( memUsage_str … " | TEXTURE= "…(system.getInfo(“textureMemoryUsed”)/1048576) )

end

timer.performWithDelay( 1000, checkMem, 0 )

[/lua]

Brent

Hi @Ducky,

A pretty standard memory checking function is as follows…

[lua]

local function checkMem()

   collectgarbage(“collect”)

   local memUsage_str = string.format( “MEMORY= %.3f KB”, collectgarbage( “count” ) )

   print( memUsage_str … " | TEXTURE= "…(system.getInfo(“textureMemoryUsed”)/1048576) )

end

timer.performWithDelay( 1000, checkMem, 0 )

[/lua]

Brent

Which scene does should I put this memory checking function into?  

What are acceptable tolerance levels?

Is there a tutorial on how to check for memory leaks?

Thanks

Lori

Hi Lori,

You can just put it inside “main.lua” and watch the output. There’s not really a “tolerance level”, but rather, you should just watch for memory creep… that is, as you navigate around from scene to scene, the memory will fluctuate, but it shouldn’t continue to climb without ever dropping back down. In other words, if you have 2 scenes (A and B) and you go back and forth from A to B, then back to A, the memory should be about the same in A. If you see that the memory continues to creep upward, then you’ve got a memory leak.

Brent

Thanks!

Which scene does should I put this memory checking function into?  

What are acceptable tolerance levels?

Is there a tutorial on how to check for memory leaks?

Thanks

Lori

Hi Lori,

You can just put it inside “main.lua” and watch the output. There’s not really a “tolerance level”, but rather, you should just watch for memory creep… that is, as you navigate around from scene to scene, the memory will fluctuate, but it shouldn’t continue to climb without ever dropping back down. In other words, if you have 2 scenes (A and B) and you go back and forth from A to B, then back to A, the memory should be about the same in A. If you see that the memory continues to creep upward, then you’ve got a memory leak.

Brent

Thanks!