Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WIP test shows leak in CollectionView
I added some logging for the sample: * dotnet#14664 * https://github.com/nacompllo/MemoryLeakEverywhere/tree/bugfix/memoryLeakItemsSource I found the "logical children" grow indefinitely on iOS/Catalyst, after adding some logging it quickly got up to 71 items: 2023-07-06 09:04:27.745 MemoryLeakEverywhere[93127:7440192] Microsoft.Maui.Controls.CollectionView added child -> Microsoft.Maui.Controls.Image, count: 71 I was able to reproduce in a test, after I added some code to allow the `CollectionView` to create items (using `WidthRequest`/`HeightRequest`). When you replace an `ItemsSource` on iOS, in this way: var newCollection = new ObservableCollection<string>(); collectionView.ItemsSource = newCollection; foreach (var item in data) { newCollection.Add(item); } It appears that the old items are not removed, the test fails with: Expected: 3 Actual: 6 But passes on Windows & Android. Somewhere, we need to call one of: * `ItemsView.ClearLogicalChildren()` * `ItemsView.RemoveLogicalChild()` But I've not been successful yet.
- Loading branch information