-
Notifications
You must be signed in to change notification settings - Fork 1.9k
.NET MAUI Shell app page navigation memory leaks #15930
Description
Description
In a .NET MAUI Shell app running on Windows it looks like pages are held in memory after navigating to and then away from the page. This results in an increase in memory over time as pages are opened and closed.
We noticed this issue as we have some particularly memory intensive pages that result in steep memory jumps as they are opened and closed.
Steps to Reproduce
Setup
- Create new Maui app. File -> New Solution -> Maui App
- Create two new MAUI ContentPages
SecondaryPageandTertiaryPage - Add
SecondaryPageto the Shell Flyout Items - Add a Button to the
SecondaryPagewith a clicked eventawait Navigation.PushAsync(new TertiaryPage());
Testing
- Run the app targeting Windows
- Navigate to the
SecondaryPagevia the Flyout - Navigate to the
TertiaryPagevia the Button onSecondaryPage - Click the back button
- Take a snapshot of the memory usage
- Navigate to the
TertiaryPagevia the Button onSecondaryPage - Click the back button
- Take a snapshot of the memory usage
- Repeat as many times as desired
Result: Looking at the memory usage snapshots the number of instances of TertiaryPage in memory increases with the number of times the page has been opened.
Expected: The page should no longer exist in memory after navigating away, the number of instances in memory should not increase as the page is repeatedly opened.
Link to public reproduction project repository
https://github.com/duffh/MauiMemoryLeakTestApp
Version with bug
8.0.0-preview.5.8529
Last version that worked well
Unknown/Other
Affected platforms
Windows, I was not able test on other platforms
Affected platform versions
Windows SDK 10.0.19041.0
Did you find any workaround?
No response
Relevant log output
No response

