Question

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

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top