The Out of Memory Monster

Recently I had a lot of trouble with an Android app because of a memory leak. In the end Eclipse's MAT was very helpful. While the automatic leak detection brought up a lot of false suspects it turned out that the OQL query "select * from instanceof android.app.Activity" was the right solution. (I guess 99% of all leaks inside Android apps are leaking activities.)

It turned out that somewhere in the code I had two inner classes which should be static with a WeakReference to the activity. One class inherited from Handler and one was a ServiceConnection. (And I was very surprised because of the later, but http://code.google.com/p/android/issues/detail?id=6426 was very helpful.)