Skip to content

Memory leak when pushing and poping a page many times #745

@fpuente70

Description

@fpuente70

🐛 Bug Report

There seems to be a memory leak in the push/pop process which can be significative after many iterations, especially on IOS.

Expected behavior

whatever is done during push/pop process should release the memory used for it to avoid memory leaks

Reproduction steps

        long memoryBefore = GC.GetTotalMemory(true);
        MyPopupPage popup = new MyPopupPage();
        for (int i = 0; i < 1000; i++)
        {
            await PopupNavigation.Instance.PushAsync(popup);
            await PopupNavigation.Instance.RemovePageAsync(popup);
        }
        GC.Collect();
        long memoryAfter = GC.GetTotalMemory(true);
        Console.WriteLine("{0:D}", memoryAfter - memoryBefore);

doing this with the base PopupPage or an empty derived class will result in no significative memory leak. However, when you start to put things on the XAML like grids, lists, labels, images, etc it starts to slowly leak memory, proportionally with the amount of elements displayed on the popup page.
The amount of memory leaked seems to be more on IOS than on Android, but they both show leaks.

Configuration

Version: 1.x
version 1.2.0.223
Platform:

  • 📱 iOS
  • 🤖 Android
  • 🏁 WPF
  • 🌎 UWP
  • 🍎 MacOS
  • 📺 tvOS
  • 🐒 Xamarin.Forms

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions