This repository has been archived by the owner on May 1, 2024. It is now read-only.
[Bug] Is XF Shell navigation leaking memory? #14657
Labels
a/performance
a/shell 🐚
i/high
Completely doesn't work, crashes, or is unusably slow, has no obvious workaround; occurs less often
t/bug 🐛
Description
Every time app adds a page to navigation stack via
Shell.Current.GoToAsync("MyPage")
a new instance is created, which is to be expected. But after navigating back (either withShell.Current.GoToAsync("..")
or with back button) that page is never released from memory or at least is seems that it is the case. I have tried to check it with a finalizer but it is never called, which may be an implementation detail but having also some private object created then its finalizer is also never called and that seems like a bug. I also tried to use Xamarin Profiler which also shows that alive objects are only growing.When using the older navigation style -
PushAsync, PopAsync
- finalizers are called properly. I will attach a minimal example app to demonstrate the issue which is just the project autogenerated by Visual Studio stripped down to just 2 pages.If this behavior is expected I would like to get a clarification how XF.Shell manages memory. Right now I am dealing with my own application which after some time only increases its memory usage and never releases it and I am wondering if XF.Shell may be responsible for that. This same issue have already been discussed here #11476 but I don't think it was resolved in any way as the responders focused on Messagin centre but I am not using that.
Steps to Reproduce
Routing.RegisterRoute
Expected Behavior
Allocated data is released when a page is removed from navigation stack.
Actual Behavior
Finalizer of the removed page or finalizer of any object the page has reference to is never called.
Basic Information
Environment
Visual Studio: Visual Studio 2019 16.9.3, 16.11.2
Screenshots
Reproduction Link
Minimal example:
ShellMemoryLeak.zip
The text was updated successfully, but these errors were encountered: