1

I was developing a game for android platforms using andengine. and i used to regularly check memory usage by application.

This was the memory usage before using spritesheets enter image description here

Later on i came to know about SpriteSheet and Andengine's TexturePackerExtension

I tried to use it in my app. I created a single spritesheet containing all the images need throughout the game.

And when i load it i got heap increased than the previous one.

enter image description here

I was assuming heap would decrease after using SpriteSheet.
What went wrong?
What should i do to manage memory using SPriteSheet and TexturePackers.

Softwares using:

  1. TexturePacker of CodeANdWeb.com
  2. AndEngine GLES2
  3. Andengine-TexturePackerExtension.

[Edit] [SOLVED]

total heap doesn't seems to be a bigger issue. I finally managed to control total heap memory.

I simple created 2 spritesheets 1 for actual game resources and other one is for menu resources. and i load only that spritesheet which is needed currently. Before loading another spritesheet i used to unload previous spritesheet and so on..

I hope this is a right approach.

After creating 2 spritesheets my heap memory never goes avobe approx 18 mb :D

enter image description here

Chaitanya Chandurkar
  • 2,142
  • 3
  • 24
  • 43

1 Answers1

1

Your total heap capacity was (probably) temporarily bigger because the spritesheet is one big chunk of data which had to be decoded into heap memory for a very brief period of time before being sent to an OpenGL texture. Your allocated heap is almost identical! So no leak or anything here!

OpenGL textures don't count against your java heap.

Nicolas Gramlich
  • 2,790
  • 19
  • 19
  • Does it mean i don't have to bother about total heap if Allocated heap are nearly same? I found my game crashes on devices like Samsung Galaxy Ace, Samsung Galaxy Y. Might be bcoz of large heap memory? – Chaitanya Chandurkar Apr 01 '13 at 16:46
  • Yes, those devices are on the cheap end and probably have less maximum heap. By using [PVR(CCZ/GZ)](https://github.com/nicolasgramlich/AndEngine/blob/GLES2-AnchorCenter/src/org/andengine/opengl/texture/compressed/pvr/PVRTexture.java) compressed textures (instead of PNG, which you are probably currently using), you can use this [PixelBufferStrategy](https://github.com/nicolasgramlich/AndEngine/blob/GLES2-AnchorCenter/src/org/andengine/opengl/texture/compressed/pvr/pixelbufferstrategy/SmartPVRTexturePixelBufferStrategy.java) which allows you to limit maximum allocation when loading the texture. – Nicolas Gramlich Apr 02 '13 at 22:13