Shell possible memory leak

Hi everyone.
Using Shell, whenever I navigate from a tab to a details page (that is registered to Shell Routes), a new instance of that page is created. But, when I leave this page the finalizer is never called, it seems to be held in memory forever. This page is an empty ContentPage, I set Content = null after popping, and I even used a GC.Collect(1, GCCollectionMode.Forced, false), but nothing.
Am I doing something terribly wrong? Is there a way that I can remove any references of the page left?
Thank you



  • LandLuLandLu Member, Xamarin Team Xamurai

    How did you know the detail page hasn't been released?
    I test the sample here:
    And create a custom renderer for cat detail page:

    [assembly: ExportRenderer(typeof(CatDetailPage), typeof(CustomPageRenderer))]
    namespace Xaminals.Droid
        public class CustomPageRenderer : PageRenderer
            public CustomPageRenderer(Context context) : base(context)
            protected override void Dispose(bool disposing)

    The Dispose event will be triggered when coming to CatsPage from CatDetailPage.

  • DaveEnartosDaveEnartos USMember

    Yes, the page renderer is disposed. I am talking about the ContentPage in the Forms library project.
    I am using the shell template application of VS 2019. I put a finalizer at theItemDetailPage and is never being called. Plus, the app memory is constantly increasing while navigating to multiple itemDetails, and does not decrease.
    On the contrary, when using the MasteDetail template application of VS 2019, the finalizer is being called at the ItemDetailPage (after a GC.Collect).

  • LandLuLandLu Member, Xamarin Team Xamurai

    What does your finalizer look like?
    Can you share a sample to specify this?

Sign In or Register to comment.