Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 58056

Dialogs leaking memory on Android

$
0
0

Take a DatePicker sample:

`public DatePickerDemoPage()
{
Label header = new Label
{
Text = "DatePicker",
Font = Font.BoldSystemFontOfSize(50),
HorizontalOptions = LayoutOptions.Center
};

        DatePicker datePicker = new DatePicker
        {
            Format = "D",
            VerticalOptions = LayoutOptions.CenterAndExpand
        };

        // Accomodate iPhone status bar.
        this.Padding = new Thickness(10, Device.OnPlatform(20, 0, 0), 10, 5);

        // Build the page.
        this.Content = new StackLayout
        {
            Children = 
            {
                header,
                datePicker
            }
        };
    }`

Show the page, click on date so the picker dialog appears. Then recreate the activity (rotate, etc.).
You'll get this in output window:

06-07 12:45:02.682 E/WindowManager( 9936): Activity xforms.droid.MainActivity has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView{52809624 V.E..... R.....I. 0,0-777,686} that was originally added here

06-07 12:45:02.682 E/WindowManager( 9936): android.view.WindowLeaked: Activity xforms.droid.MainActivity has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView{52809624 V.E..... R.....I. 0,0-777,686} that was originally added here
06-07 12:45:02.682 E/WindowManager( 9936): at android.view.ViewRootImpl.(ViewRootImpl.java:345)
06-07 12:45:02.682 E/WindowManager( 9936): at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:239)
06-07 12:45:02.682 E/WindowManager( 9936): at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:69)
06-07 12:45:02.682 E/WindowManager( 9936): at android.app.Dialog.show(Dialog.java:281)
06-07 12:45:02.682 E/WindowManager( 9936): at xamarin.forms.platform.android.DatePickerRenderer_TextFieldClickHandler.n_onClick(Native Method)
06-07 12:45:02.682 E/WindowManager( 9936): at xamarin.forms.platform.android.DatePickerRenderer_TextFieldClickHandler.onClick(DatePickerRenderer_TextFieldClickHandler.java:29)
06-07 12:45:02.682 E/WindowManager( 9936): at android.view.View.performClick(View.java:4240)
06-07 12:45:02.682 E/WindowManager( 9936): at android.view.View$PerformClick.run(View.java:17721)
06-07 12:45:02.682 E/WindowManager( 9936): at android.os.Handler.handleCallback(Handler.java:730)
06-07 12:45:02.682 E/WindowManager( 9936): at android.os.Handler.dispatchMessage(Handler.java:92)
06-07 12:45:02.682 E/WindowManager( 9936): at android.os.Looper.loop(Looper.java:137)
06-07 12:45:02.682 E/WindowManager( 9936): at android.app.ActivityThread.main(ActivityThread.java:5103)
06-07 12:45:02.682 E/WindowManager( 9936): at java.lang.reflect.Method.invokeNative(Native Method)
06-07 12:45:02.682 E/WindowManager( 9936): at java.lang.reflect.Method.invoke(Method.java:525)
06-07 12:45:02.682 E/WindowManager( 9936): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
06-07 12:45:02.682 E/WindowManager( 9936): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
06-07 12:45:02.682 E/WindowManager( 9936): at dalvik.system.NativeStart.main(Native Method)


Viewing all articles
Browse latest Browse all 58056

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>