Hi,

it seems that 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 line

android:background="@drawable/wallpaper"

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 with every turn. Turning the device several times (about 7
times with a 1280x1024 image) causes an exception because we are already
running out of memory.

To verify the problem 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.

I assume that Mono for Android somewhere keeps a persistent internal
reference to every Activity that is ever created and never releases it. Thus
all resources attached to an Activity are never released, too.

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)
                {
                        base.OnCreate(bundle);
                        SetContentView(Resource.Layout.Main);
                }
        }
}

and still, the memory of the background image and probably more is leaked.

BTW: Sure I could use a smaller image or maybe no background image at all.
But this would only defer the problem and not solve it.

Cheers,

Andreas


--
View this message in context: 
http://mono-for-android.1047100.n5.nabble.com/Memory-Leak-with-Background-Image-tp5165833p5165833.html
Sent from the Mono for Android mailing list archive at Nabble.com.
_______________________________________________
Monodroid mailing list
Monodroid@lists.ximian.com

UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid

Reply via email to