1
\$\begingroup\$

I'm using LibGDX for my game. I'm loading 9 bitmaps into memory at once using the AssetManager, about 512x512 pixels each on average.

TextureParameter texParam = new TextureParameter();
texParam.format = Format.RGBA8888;

assetManager.load("islands/island_0.png", Texture.class, texParam);
assetManager.load("islands/island_1.png", Texture.class, texParam);
assetManager.load("islands/island_2.png", Texture.class, texParam);
assetManager.load("islands/island_3.png", Texture.class, texParam);
assetManager.load("islands/island_4.png", Texture.class, texParam);
assetManager.load("islands/island_5.png", Texture.class, texParam);
assetManager.load("islands/island_6.png", Texture.class, texParam);
assetManager.load("islands/island_7.png", Texture.class, texParam);
assetManager.load("islands/island_8.png", Texture.class, texParam);

However, if I switch the format to Format.RGB565, then run the Heap allocation tracker in the DDMS view of Eclipse, I see absolutely no change in the memory allocated. The bitmaps being drawn on the screen though are being rendered differently (without an alpha channel when I use RGB565).

Am I missing something? Why aren't the bitmaps using less memory?

\$\endgroup\$
3
  • \$\begingroup\$ Does the asset manager actually reformat the data as it loads it in? Format specifiers such as RGBA8888 are often simply used to specify how the data is to be interpreted, as in how it is already formatted. Unless the asset manager changes the format itself, your textures are still going to be the same size they were created at, except now the GPU will see them differently. \$\endgroup\$
    – Evan
    Oct 16, 2013 at 17:55
  • \$\begingroup\$ @Evan, Hmm, so how would I get textures of smaller size? Is there a certain PNG option I set when saving the original files? Or is some switch I have to turn on in the LibGDX engine somewhere? \$\endgroup\$
    – you786
    Oct 17, 2013 at 5:11
  • \$\begingroup\$ Unless you have a system programmed to reformat your textures, this is typically done through an art tool such as photoshop, gimp, or using a dedicated formatting/conversion tool. Or, your art department if you have one :P. I don't honestly have any experience with libgdx, this is just from my own personal opengl/directx experience. \$\endgroup\$
    – Evan
    Oct 17, 2013 at 13:51

1 Answer 1

2
\$\begingroup\$

http://developer.android.com/tools/debugging/ddms.html#heap

DDMS allows you to view how much heap memory a process is using.

Textures are allocated in GPU memory, not heap memory. This would be expected behaviour.

\$\endgroup\$
1
  • \$\begingroup\$ According to this answer (by an Android framework engineer) stackoverflow.com/a/1949205/458968 you should be able to count the bitmap allocations against the heap. But I'm not sure if this applies to LibGDX. \$\endgroup\$
    – you786
    Oct 16, 2013 at 17:43

You must log in to answer this question.

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