I try to load a lot of texture atlases (10) with approximately 5 (~2048x~2048)(not using PoT) .pngs each. I'm using AssetManager and there is no trouble with it on my pc but when I try it on my tablet the app just dies without any error messages or crash reports and there aren't any outOfMemoryExceptions.

Here's my log:

the max memory: 67 is

Runtime().getRuntime().maxMemory() / 1000000


I'm running out of ideas of what to do. Maybe I don't fully understand the way mobile games work: is that a lot of atlases (I have other textures not atlases apart from these atlases)? because everything looks quite fine in the memory segment as much as I know. Anyway I'm open to suggestions and maybe some tips. And I'd really like to keep these atlases in my game.

EDIT: the game loads on my tablet but not phone when I use 1 png per atlas (8192x8192) but my tablet doesn't show images larger than 2048x2048 for some reason oh and the images in the atlas aren't even 1024x1024 so idk why it doesn't show them must be because the atlas is 8192x8192.

EDIT #2: I load only atlases now, no separate .png files and I am now using PoT (2048x2048). 17 atlases some have 2 pngs some even have 1 png but there are some that have 5+ and that's my level plus player animations plus I'm using a gradient for my whole level that is ~10000px in width combined and I use FBO to do a Lighten shader on the level and my level has animations. Is that too much? Anyway this time the game died @ 94% on my phone(Galaxy S2) and @ 58% on my tablet(Lenovo IdeaTab A2109) and here's my new log but this time from my phone:

I'm confused because there aren't any outOfMemory exceptions and I'm disposing every possible thing there is to dispose. btw my app in the logs is com.comraz.slashem Is theree something I can do? f.e. downscale textures or use mipmaps or something? my level textures are 1024x768 when zoomed in and 1024x1536 when zoomed out. If you have any ideas or any questions please do ask or tell me. Oh and my camera size is 1280x768

• What device do you have? – Vaughan Hilts Jan 7 '14 at 2:42
• @VaughanHilts I have a Samsung Galaxy S2 and a Lenovo IdeaTab A2109 – jos_fzr Jan 7 '14 at 2:43
• Have you tried dropping the bit depth of the images? – Vaughan Hilts Jan 7 '14 at 2:46
• @VaughanHilts I tried compressing my atlases and I lost ~70% of the size of each atlas png – jos_fzr Jan 7 '14 at 3:00
• Not compress -- just lower their colour count – Vaughan Hilts Jan 7 '14 at 3:10

The amount of memory required for your 17 textures at 2048x2048 using 32-bit color is:

17 * 2048 * 2048 * 4 = ~272MB


It's not too excessive, but that is just for graphics and it does not account for memory used by other assets (audio, etc), background tasks, OS usage, etc.

You may need to load the bitmap using a lower color depth to conserve memory. It's a trade off between quality and resource usage, and is very important on mobile devices with lower memory.

If you are using glTexImage2D() for loading, specify a lower bpp value using the internalFormat argument - set it to some value like GL_RGB5 (for 16bit color, which will only use half the amount of space). This will degrade your graphics but might help on devices with lower memory.

Another option is to lower the resolution of your textures.

• Weird, libgdx does not automatically scale this back? – Vaughan Hilts Jan 23 '14 at 16:35