Serious MAUI (ClientApp) memory leak problem
In recent days our company discovered serious memory leak in MAUI app we are working on i.e. views set as transient don't get disposed of correctly resulting in linear memory growth. Firstly we tried using MAUI wiki page on memory leaks, which yield no concrete results to our problem. Our team decided look up how it is done in eShop demo, and we found same leak here.
In demo we added GC.Collect, destructors to each view (on which we put a breakpoints) and label (under "Adventure Works'" title) that displays current heap size.
Examples below:
Cheap size on startup:
Cheap size after opening and closing BasketView 10 times
On opening and closing BasketView breakpoints weren't triggered single time and heap size kept increasing.
After deleting command from button in BasketView destructor started working.
Questions
Why does it happen, is there some explanation to why MAUI behaves this way? If it is not problem with MAUI, then where lays that issue? Do we need to use some practices that aren't shown in this demo?
Let me ping @jonathanpeppers to see if this with the app or is this with .NET MAUI itself somewhere
@DarrenStasiak can you try the latest service release?
- https://github.com/dotnet/maui/releases/tag/8.0.70
The past few releases have fixed various memory issues. dotnet/eShop/main already has dependabot updates for this one.
The next question I have, what does {Binding CheckoutCommand} bind to?
It seems like the issue could be similar to:
- https://github.com/dotnet/maui/issues/16124
Do you have a custom ICommand where CanExecuteChanged is not backed by a "weak event"?
I just updated the packages to 8.0.70 so should be a quick pull to test
Will close out as now on newer versions and working on .NET 9