Optimize texture memory on Android devices

Hi guys, the game I’m making runs smoothly on iOS devices, but not on Android devices.

I think that’s because the used texture memory is almost 160MB.

In order to avoid memory leakage, I’ve inserted all of the images used in the game into a table, and all the variables I’m currently using are “local”.

I’ve even followed a lot of tutorial about memory optimization, and my game meets all the requirements (or at least I think)

So usually, how do you optimize the Texture memory in your apps?

For your information, my game is an endless runner game, and I’m loading all the images when the app is launched.  

Thanks in advantage.

160MB seems like a lot. How large are your images?

Hi @memo, in terms of resolution, the biggest one is 1423x800, while in terms of size the average is 140kb

That’s a very large image. It’s a good idea to keep your image sizes small and in powers of 2, as otherwise you’ll be wasting a lot of memory. An image of 1423x800 takes up ~8MB of memory, just for that one image. For comparison, the whole game I’m currently working on uses about 17MB total.

I suggest you read this if you haven’t already, it explains the power-of-two rule and contains some additional tips: http://docs.coronalabs.com/guide/basics/optimization/index.html

Also, loading every single image into memory when starting up your app isn’t always the right approach. If there are images which aren’t used very often, it may be better to load them on the fly.

160MB seems like a lot. How large are your images?

Hi @memo, in terms of resolution, the biggest one is 1423x800, while in terms of size the average is 140kb

That’s a very large image. It’s a good idea to keep your image sizes small and in powers of 2, as otherwise you’ll be wasting a lot of memory. An image of 1423x800 takes up ~8MB of memory, just for that one image. For comparison, the whole game I’m currently working on uses about 17MB total.

I suggest you read this if you haven’t already, it explains the power-of-two rule and contains some additional tips: http://docs.coronalabs.com/guide/basics/optimization/index.html

Also, loading every single image into memory when starting up your app isn’t always the right approach. If there are images which aren’t used very often, it may be better to load them on the fly.