forked from dotnet/maui
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[core] fix memory leak with
CarouselView
& INotifyCollectionChanged
Context: dotnet#17726 In investigating dotnet#17726, I found a memory leak with `CarouselView`: 1. Have a long-lived `INotifyCollectionChanged` like `ObservableCollection`, that lives the life of the application. 2. Set `CarouselView.ItemsSource` to the collection. 3. `CarouselView` will live forever, even if the page is popped, etc. I further expanded upon `MemoryTests` to assert more things for each control, and was able to reproduce this issue. To solve the problem, I used the same technique in 58a42e5. We can use `WeakNotifyCollectionChangedProxy` in the `ObservableItemsSource` class to prevent `CarouselView` from leaking. `ObservableItemsSource` is used for other controls, so this may fix other leaks as well. Unfortunately, this does not fully solve dotnet#17726, as there is at least one further leak on Android from my testing.
- Loading branch information
1 parent
0049595
commit c3c996b
Showing
3 changed files
with
23 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters