2

I'm working on an Android app using Open GL ES 2.0. I'm confused about memory management in Open GL.

My questions are:

  • How much memory is available to the Open GL hardware? Clearly it's going to vary from device to device.
  • How can I find out how much memory is in use and how much is left?
  • What happens if I exceed the memory limits?
  • What techniques should I be using to unload data not currently being displayed?

I presume I'm going to have to implement some kind of system to unload textures that are not currently in use on an LRU basis, but I'd like some idea of what criteria to use for this. The app silently dies at some point and I suspect it is because I'm using too much graphics memory.

Currently I'm never unloading textures and I seem to be able to load quite a few - testing on a Nexus 7 I have been able to load 134 1024x1024 RGBA textures, which I calculate to be over 500MB. I presume once the textures have been loaded into graphics memory they take up less space, but that's still a lot, and clearly I have to manage that but I'd like some tips on how to start.

Clyde
  • 7,389
  • 5
  • 31
  • 57

1 Answers1

0

Simply use gles glDeleteTextures

If you run out of memory you will gen GL_OUT_OF_MEMORY error probably. Another thing is to monitor memory usage in Android.

android memory: How do I discover memory usage of my application in Android?

See here an interesting question for opengl: how to manage memory with texture in opengl?

Community
  • 1
  • 1
fen
  • 9,835
  • 5
  • 34
  • 57
  • On the device I'm currently using for testing there is no error if I fill up the memory - the app just silently dies. The only clue in the logcat is a message about window death. I am calling glGetError after loading each bitmap. – Clyde Aug 25 '13 at 21:37
  • do you use glGetError properly? http://blog.nobel-joergensen.com/2013/01/29/debugging-opengl-using-glgeterror/ you should check it in a loop. Maybe it is not a GL problem... maybe Android cannot load a texture? – fen Aug 26 '13 at 06:42