-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Memory leaks EVERYWHERE #12039
Copy link
Copy link
Closed
Labels
delighterfixed-in-8.0.0-preview.1.7762Look for this fix in 8.0.0-preview.1.7762!Look for this fix in 8.0.0-preview.1.7762!legacy-area-perfStartup / Runtime performanceStartup / Runtime performancep/0Current heighest priority issues that we are targeting for a release.Current heighest priority issues that we are targeting for a release.partner/cat 😻this is an issue that impacts one of our partners or a customer our advisory team is engaged withthis is an issue that impacts one of our partners or a customer our advisory team is engaged withperf/generalThe issue affects performance (runtime speed, memory usage, startup time, etc.) (sub: perf)The issue affects performance (runtime speed, memory usage, startup time, etc.) (sub: perf)platform/windowst/bugSomething isn't workingSomething isn't working
Milestone
Metadata
Metadata
Assignees
Labels
delighterfixed-in-8.0.0-preview.1.7762Look for this fix in 8.0.0-preview.1.7762!Look for this fix in 8.0.0-preview.1.7762!legacy-area-perfStartup / Runtime performanceStartup / Runtime performancep/0Current heighest priority issues that we are targeting for a release.Current heighest priority issues that we are targeting for a release.partner/cat 😻this is an issue that impacts one of our partners or a customer our advisory team is engaged withthis is an issue that impacts one of our partners or a customer our advisory team is engaged withperf/generalThe issue affects performance (runtime speed, memory usage, startup time, etc.) (sub: perf)The issue affects performance (runtime speed, memory usage, startup time, etc.) (sub: perf)platform/windowst/bugSomething isn't workingSomething isn't working
Type
Fields
Give feedbackNo fields configured for issues without a type.
Description
I'm trying to develop LoB app in MAUI, including lot's of CollectionViews and complex master-details with multiple views, data forms and custom controls. It's bumpy road, but by far the most critical issue for me is the amount of memory leaks, which makes the app completely unusable.
I have already reported 2 issues resulting in severe memory leak and there have been many more raised over time by others. Unfortunately they aren't getting attention they deserve in my opinion.
The more I look into this topic, the more puzzled I'm by memory management in MAUI and the more I'm determined that there is something horribly wrong happening inside MAUI. I decided to create another sample to demonstrate this issue and it's significance for production apps. The sample is very simple MVVM app with CollectionView of Items. Clicking on an item will bring you to a detail page.
This bit in DetailPage constructor was added to increase memory allocation of the detail to make the memory leak more obvious (Array.Clear(Bytes) causes array to be iterated and allocated):
If you keep navigating back and forth from master to its details and watch memory usage, you will see memory raising from 100 MBs to several GBs very quickly. I added button to execute GC.Collect(), but forcing GC never disposes all the resources.

Calling this to manually free some resources doesn't seem to have any effect.
I made several observations:
The issue is obvious in other samples as well, for example Monkey app by @jamesmontemagno
https://github.com/dotnet-presentations/dotnet-maui-workshop
Note that there is no use of static resources or event subscription anywhere in the sample code.
I observed the issue only in Windows as I have no sufficient way to check memory in other platforms.
Any tips about how to dispose DetailPage with all the related resources would be very welcomed.
Steps to Reproduce
Link to public reproduction project repository
https://github.com/Vroomer/MAUI-master-detail-memory-leak.git
Version with bug
7.0 (current)
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.22000
Did you find any workaround?
No response
Relevant log output
No response