Hello all.
I followed each and every tip in this forum to prevent my game from leaking memory and I tought I could do it.
I use the following code snippet, that I found somewhere here in the forum, to show the current memory used:
function checkMemory() collectgarbage( "collect" ) local memUsage\_str = string.format( "MEMORY = %.3f KB", collectgarbage( "count" ) ) print( memUsage\_str, "TEXTURE = "..(system.getInfo("textureMemoryUsed") / (1024 \* 1024) ) ) end timer.performWithDelay( 1000, checkMemory, 0 )
First the memory and texture rises constantly to a maximum of about
memory = 1500.000 kb texture = 14
while playing.
(While testing with a huge amount of display objects running around, way more than the game will actually use. (Normal use is about 1200 kb memory))
When I return to my main menu, the memory falls down to a stable value.
If I repeat this many times, like: main --> playing the game --> main --> playing the game --> main, …
it always return to the same values for memory and texture.
Now the problem is, that if I go to the android application manager the RAM used by the game is constantly rising. It starts at about 30 mb and after some time I am at 200 mb, rising further.
This is not good, because this slows the game down, by the time although collectgarbage( “count” ) says, I am using the same memory than in the beginning.
Does somebody know why the values from collectgarbage( “count” ) are different from the actual values or has same problems and know how to solve them?
Or am I wrong and I missunderstand something?
Thanks in advance,
Felix