-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[controls] fix memory leak in
CollectionView
(#14329)
Fixes: #10578 Context: https://github.com/Vroomer/MAUI-navigation-memory-leak.git After testing the above sample, I found that adding a `CollectionView` to a `Page`, makes it and the entire page live forever. Android & Windows: * `MauiRecyclerView` and `StructuredItemsViewHandler` respectively subscribed to `ItemsLayout.PropertyChanged`. This kept the `CollectionView` alive -> all the way up to the `Page`. * Switched to using `WeakNotifyPropertyChangedProxy` solved the issue for these two platforms. iOS: * Generally had a small "nest" of circular references. Initially, I saw `CollectionView`, `UICollectionView`, and various helper classes that would live forever. * `ItemsViewController : UICollectionViewController` -> * `ObservableItemsSource` -> * `UICollectionViewController` and `UICollectionView` * `UICollectionView` -> * `ItemsViewLayout : UICollectionViewFlowLayout` -> * `Func<UICollectionViewCell>` -> * `ItemsViewController : UICollectionViewController` -> * `UICollectionView` I switched to using `WeakReference<T>` to break the circular references. This required several null checks, where `null` references were not possible before. After these changes my tests pass, yay!
- Loading branch information
1 parent
e8039c9
commit 84128e6
Showing
14 changed files
with
114 additions
and
46 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
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
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
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
Oops, something went wrong.