Excessive garbage collection App freezes

I am using mte for handling tiles, spine for animations. I have lot of image sheets say more than 30 mb. 

While playing the game at some point of time say after 30 sec my app suddenly freezes for a sec and then continues normally .

I found the reason once the garbage collection is done its get freezing . What should i do avoid this scenario?

How do i handle this garbage collection ?

Thanks,

Kumar KS.

I’d start by checking how many objects are being created / released by the garbage collector every frame and print it to the screen (see https://docs.coronalabs.com/api/library/global/collectgarbage.html).  The function collectgarbage(“count”) will tell you about how much memory is being used by the garbage collector, which is a good indicator of where things may be going wrong.

I’d also look at your image sheets and see if you can pack them more effectively.  Remember, Corona will extend your images so their dimensions are a power of 2 in either direction.  This means if one of your images is 513x640, it will take up the same space as a 1024x1024 image.  If you’ve got lots of image sheets, that extra texture memory soon adds up and will destroy your app’s performance.

There’s a tutorial on performance optimisation that may help here: https://coronalabs.com/blog/2013/03/12/performance-optimizations/

I’d start by checking how many objects are being created / released by the garbage collector every frame and print it to the screen (see https://docs.coronalabs.com/api/library/global/collectgarbage.html).  The function collectgarbage(“count”) will tell you about how much memory is being used by the garbage collector, which is a good indicator of where things may be going wrong.

I’d also look at your image sheets and see if you can pack them more effectively.  Remember, Corona will extend your images so their dimensions are a power of 2 in either direction.  This means if one of your images is 513x640, it will take up the same space as a 1024x1024 image.  If you’ve got lots of image sheets, that extra texture memory soon adds up and will destroy your app’s performance.

There’s a tutorial on performance optimisation that may help here: https://coronalabs.com/blog/2013/03/12/performance-optimizations/