Friday, June 1, 2012

Memory Management in Android

Some commonly encountered memory management issues in Android:

http://android-developers.blogspot.com/2009/01/avoiding-memory-leaks.html
  • Ensure that Activity Context objects don't outlive their Activities.
  • Note when callbacks are likely to cause issues with circular references or major items not being GC'ed
Other notes from experience and research:
  • The HTC Dream has 16MB of Heap Memory.
  • The debugger does not report heap utilized by bitmaps, resulting in OutOfMemoryError even when heap consumption is reported at merely 2MB.
  • Ensure that all threads are killed.
  • Watchout for circular references.
  • Inflated bitmaps are 2 bytes per pixel if no alpha, and 4 bytes per pixel if has alpha.
Some useful links:

No comments:

Post a Comment