Massive Memory Leak with Background Image

Bitmap images attached as background drawables are never released.

In order to re-create the problem just create a default Mono for Android project and add the XML attribute


to the outer LinearLayout. Also add a wallpaper.png image (make it large to quickly see the problem, e.g. 1280x1024 pixels) to the resources drawable folder. Then start the application.

When turning the orientation of the device (portrait/landscape) the activity is re-created by Android with every turn. Turning the device several times (about 7 times with a 1280x1024 image) causes an exception and terminates the App because we are already running out of memory.

I even trimmed down the default application to just

namespace MonoAndroidApplication2

        [Activity(Label = "MonoAndroidApplication2", MainLauncher = true)]
        public class Activity1 : Activity
                protected override void OnCreate(Bundle bundle)


and still, at least the memory of the background image is leaked with every turn of the device.

To verify that the problem is with Mono and not with Android itself, I also created a Java Android default application and made the very same changes to it, using the very same image. Needless to say, the real Android application does never exhaust its memory.