Question: I've got an Android app developed, and I'm at the point of a phone app development where everything seems to be working well and you want to declare victory and ship, but you know there just have to be some memory and resource leaks in there; and there's only 16mb of heap on the Android and its apparently surprisingly easy to leak in an Android app.

I've been looking around and so far have only been able to dig up info on 'hprof' and 'traceview' and neither gets a lot of favorable reviews. 

What tools or methods have you come across or developed and care to share maybe in an OS project?

Answer: 
The answer from @hp.android works well if you are just working with bitmap backgrounds but, in my case, I had a `BaseAdapter` providing a set of `ImageView`s for a `GridView`. I modified the `unbindDrawables()` method as advised so that the condition is:

```
if (view instanceof ViewGroup && !(view instanceof AdapterView)) {
  ...
}

```

but the problem then is that the recursive method never processes the children of the `AdapterView`. To address this, I instead did the following:

```
if (view instanceof ViewGroup) {
  ViewGroup viewGroup = (ViewGroup) view;
  for (int i = 0; i < viewGroup.getChildCount(); i++)
    unbindDrawables(viewGroup.getChildAt(i));

  if (!(view instanceof AdapterView))
    viewGroup.removeAllViews();
}

```

so that the children of the `AdapterView` are still processed -- the method just doesn't attempt to remove all children (which is unsupported).

This doesn't quite fix the problem however since `ImageView`s manage a bitmap that is not their background. I therefore added the following. It's not ideal but it works:

```
if (view instanceof ImageView) {
  ImageView imageView = (ImageView) view;
  imageView.setImageBitmap(null);
}

```

Overall the `unbindDrawables()` method is then:

```
private void unbindDrawables(View view) {
  if (view.getBackground() != null)
    view.getBackground().setCallback(null);

  if (view instanceof ImageView) {
    ImageView imageView = (ImageView) view;
    imageView.setImageBitmap(null);
  } else if (view instanceof ViewGroup) {
    ViewGroup viewGroup = (ViewGroup) view;
    for (int i = 0; i < viewGroup.getChildCount(); i++)
    unbindDrawables(viewGroup.getChildAt(i));

    if (!(view instanceof AdapterView))
      viewGroup.removeAllViews();
  }
}

```

I'm hoping there is a more principled approach to freeing up such resources.
Well, those are the tools that hook with the unique formats that Android uses..I think what you may be unsatisfied with is the underlying testing code framework in use..

Have you tried mock testing areas of code using the Android Mock Framework?