You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
CollectionView is not currently being Garbage Collected #20710
changed the title [-]CollectionView with ItemsSource Binding is not currently being Garbage Collected[/-][+]CollectionView is not currently being Garbage Collected[/+]on Feb 24, 2024
As I observed, the CollectionView also leaks when setting the ItemsSource in the code behind directly.
The CollectionView seems to leak as long as the ItemTemplate is not "empty", e.g. as long as it contains some "real" elements like the Label in my sample.
Activity
[-]CollectionView with ItemsSource Binding is not currently being Garbage Collected[/-][+]CollectionView is not currently being Garbage Collected[/+]marco-skizza commentedon Feb 24, 2024
As I observed, the
CollectionViewalso leaks when setting theItemsSourcein the code behind directly.The
CollectionViewseems to leak as long as theItemTemplateis not "empty", e.g. as long as it contains some "real" elements like theLabelin my sample.jonathanpeppers commentedon Mar 14, 2024
@marco-skizza can you add some
GC.Collect()calls to test this? See:marco-skizza commentedon Mar 15, 2024
Hi @jonathanpeppers
The
GC.Collect()is in theMainPage.xaml.csafter navigating back again from the page with theCollectionView:https://github.com/marco-skizza/MauiCollectionView/blob/756c7e874465aee645a7ebe59bffa3555ee68bfa/MauiCollectionView/MainPage.xaml.cs#L15-L21
But tell me if I should add some more of those calls to the
OnAppearing()to make it more deterministic...P.S.:
With the current code I have to navigate forth and back several times to see the effect of
GC.Collect().P.P.S.:
I tested this with the
Debugbuild. But so far, this approach was good enough for me.22 remaining items
brentpbc commentedon Apr 15, 2024
@jonathanpeppers Thanks for looking at this :)
[ios/catalyst] fix memory leak with CollectionView (#21850)
[net8.0] Merge main to net8.0 (#22219)