Dotnet 9 Memory leaks: ViewModel with lists always stays in memory + BindableLayout leaks #26042
Labels
potential-regression
This issue described a possible regression on a currently supported version., verification pending
t/bug
Something isn't working
Milestone
Description
After updating to .Net 9, i have 2 new memory leak behaviors:
1 ViewModel never removed if it contains a collection that is the ItemsSource of some control:**If a ViewModel, which is the BindingContext of a page, contains a collection (List, ObservableCollection ..etc), and that collection is bound to the ItemsSource of a control (BindableLayout, CollectionView ...etc) ====> The ViewModel is never garbage collected !I would like to specify that the control in question IS garbage collected, no issues on the display level, it's the ViewModel itself that stays in memoryThis bahavior is consistent across platforms (tested Android, IOS and Windows)To be ignored i was just a mistake on my part ^^'
2 BindableLayout nested inside another control such as CarouselView, CollectionView or another BindableLayout is never garbage collected
In this case, not only the ViewModel remains in memory, but the BindableLayout (Grid, AbsoluteLayout, StackLayout...whatever) and, of course, this leak cascades and THE ENTIRE PAGE remains in memory!!!!
This behavior is only reproducable on IOS, on Android and Windows the page is garbage collected
Might be important: The combo CollectionView inside CollectionView doesn's cause an issue, only BindableLayout inside some other collection (in my example it's a BindableLayout inside a CarouselView)
Steps to Reproduce
Link to public reproduction project repository
https://github.com/GUELIANEBelkacem/BindableLayoutLeakyApp.git
Version with bug
9.0.10 SR1
Is this a regression from previous behavior?
Yes, this used to work in .NET MAUI
Last version that worked well
8.0.92 SR9.2
Affected platforms
iOS, Android, Windows
Affected platform versions
Latest
Did you find any workaround?
Quit my job :)
Relevant log output
The text was updated successfully, but these errors were encountered: