Android - Detect OpenGLRenderer out of memory

2.9k views Asked by At

is there a way to detect that OpenGLRenderer has run out of memory ? I'm setting big image as drawable to ImageView background and on device with FullHD display sometimes the ImageView stays blank and I get this in logcat

D/OpenGLRenderer﹕ GL error from OpenGLRenderer: 0x505
E/OpenGLRenderer﹕ Out of memory!

I'd like to detect this has happened and set smaller image as background.
Thanks

1

There are 1 answers

0
TheJudge On BEST ANSWER

Hasn't happened in a long time since I asked this question. What i would do know is

  1. Place your images in drawable-nodpi folder, Android OS usually does some resizing with images in hdpi mdpi etc folders
  2. I wouldn't set a high resolution image as background in first place
  3. Use SVG if your graphic designer can make them and the picture can be made as SVG
  4. Most of today's devices have enough RAM for loading big images so it shouldn't really be an issue

hope it helps ...