Understanding the memory consumption on iPhone

I highly doubt this is a bug in Instruments.

First, read this blog post by Jeff Lamarche about openGL textures:

  • has a simple example of how to load
    textures without causing leaks
  • gives understanding of how “small”
    images, get once they are loaded
    into openGL, actually use “a lot” of memory

Excerpt:

Textures, even if they’re made from
compressed images, use a lot of your
application’s memory heap because they
have to be expanded in memory to be
used. Every pixel takes up four bytes,
so forgetting to release your texture
image data can really eat up your
memory quickly.

Second, it is possible to debug texture memory with Instruments. There are two profiling configurations: OpenGL ES Analyzer and OpenGL ES Driver. You will need to run these on the device, as the simulator doesn’t use OpenGL. Simply choose Product->Profile from XCode and look for these profiles once Instruments launches.


Armed with that knowledge, here is what I would do:

  • Check that you’re not leaking memory — this will obviously cause this problem.
  • Ensure your’e not accessing autoreleased memory — common cause of crashes.
  • Create a separate test app and play with loading textures individually (and in combination) to find out what texture (or combination thereof) is causing the problem.

UPDATE: After thinking about your question, I’ve been reading Apple’s OpenGL ES Programming Guide and it has very good information. Highly recommended!

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)