0
\$\begingroup\$

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:

DropBox link

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:

DropBox link log_new

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

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

1 Answer 1

0
\$\begingroup\$

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.

\$\endgroup\$
1
  • \$\begingroup\$ Weird, libgdx does not automatically scale this back? \$\endgroup\$ Jan 23, 2014 at 16:35

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .