Skip to content

Android: memoryleaks when programmatically changing the Detail of a FlyoutPage #34158

@3sRykaert

Description

@3sRykaert

Description

When changing the Detail (= setting another page) of a FlyoutPage programmatically, the previous Detail ain't cleaned up. This causes memoryleaks and a slow and crashing app after browsing to pages.
Relevant code:

if (Application.Current.Windows[0].Page is FlyoutPage flyoutPage)
  flyoutPage.Detail = new NavigationPage(new DetailPage2());

No leaks when not using a new NavigationPage (but no workaround for my app, since i need the "hamburger menu"

if (Application.Current.Windows[0].Page is FlyoutPage flyoutPage)
  flyoutPage.Detail = new DetailPage2();

Steps to Reproduce

  1. Run the App on an android device
  2. In DetailPage1 click the button to navigate to DetailPage2
  3. Wait a few seconds and the nuget package from https://github.com/AdamEssenmacher/MemoryToolkit.Maui "displays" all the leaks from DetailPage1 in an Alert popup
  4. In DetailPage2 click the button to navigate to DetailPage1
  5. Wait a few seconds and the nuget package from https://github.com/AdamEssenmacher/MemoryToolkit.Maui "displays" all the leaks from DetailPage1 in an Alert popup

Link to public reproduction project repository

https://github.com/3sRykaert/MauiMemoryleak/tree/FlyoutpageIssue (make sure to use branch FlyoutpageIssue)

Version with bug

10.0.40

Is this a regression from previous behavior?

Yes, this used to work in Xamarin.Forms

Last version that worked well

Unknown/Other

Affected platforms

Android

Affected platform versions

Android 11 and up (didn't test on other platforms)

Did you find any workaround?

No

Relevant log output

Metadata

Metadata

Assignees

No one assigned

    Labels

    t/bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions