Android memory leak?

Here are a couple of articles and posts, which probably help you to get on the right track:

Allocation tracker, which comes with Android SDK is very useful. Read Romain Guy's articles. It helped me to track down pretty nasty leaks. It also helps you to write better software. E.g. I learned to create less objects, use more StringBuilder, and cache a lot more:
What Android tools and methods work best to find memory/resource leaks?

Sometimes your app is just so messed up that you have to re-design it in the whole. Here are official, good hints for that (my favourite is the Avoid Creating Unnecessary Objects):
http://developer.android.com/guide/practices/design/performance.html


Here's an excellent article about attacking your memory issues:
http://ttlnews.blogspot.com/2010/01/attacking-memory-problems-on-android.html

Official article about avoiding memory leaks:
http://android-developers.blogspot.co.uk/2009/01/avoiding-memory-leaks.html

Read also this: tool to check memory leaks in android


Others already pointed about bitmaps. Here's an article describing the issue: http://zrgiu.com/blog/2011/01/android-bitmaps-and-out-of-memory-errors/


This is not a memory leak. Android devices just have a limited amount of memory and your bitmaps must just be too big. You need to find a way to reduce the size of your bitmaps. I really can't tell you much more because you haven't given us much to go on.


When dealing with Bitmaps in android, make sure you recycle the bitmap whenever you are done using it. You can load a resized bitmap by setting the inSampleSize option. More details here: http://developer.android.com/reference/android/graphics/BitmapFactory.Options.html#inSampleSize


A typical value of max application VM heap size is 24 MB. So, for instance, if your image is 10Mpx (3600 x 2400), then it would allocate 3600 x 2400 x 4 = 34'560'000 bytes which is an OutOfMemoryError case.