Page-level memory leak in NavigationPage on iOS
AdamEssenmacher opened this issue · 3 comments
Description
NavigationPages are on iOS are not garbage collected after being removed.
Page-level leaks are serious, as they prevent child elements (in this case, whole child pages) from being collected as well.
Steps to Reproduce
- Set Application.Current.MainPage to a NavigationPage
- Swap Application.Current.MainPage with a different page
- Force GC runs
- Observe navigation page (and its children) never collected
Link to public reproduction project repository
https://github.com/AdamEssenmacher/iOSNavigationPageLeak.Maui
Version with bug
8.0.3
Is this a regression from previous behavior?
Not sure, did not test other versions
Last version that worked well
Unknown/Other
Affected platforms
iOS
Affected platform versions
iOS 17.2
Did you find any workaround?
Calling DisconnectHandler()
on the NavigationPage's Handler before removing it from use will prevent the navigation page and its children from leaking.
Relevant log output
No response
Would the area/perf label be appropriate here as well? This issue causes entire pages (and possibly nav stacks) not to be GC'ed, which causes noticeable performance degradation once the app starts needing swap space, and ultimately leading to forced app termination.
We've added this issue to our backlog, and we will work to address it as time and resources allow. If you have any additional information or questions about this issue, please leave a comment. For additional info about issue management, please read our Triage Process.
Can repro this issue at iOS platform on the latest 17.10 Preview 6(8.0.3/8.0.21).