Memory leak in ListView when deleting an item from the ItemsSource
#3,396 opened on Jul 25, 2018
Repository metrics
- Stars
- (5,644 stars)
- PR merge metrics
- (No merged PRs in 30d)
Description
Description
If you bind a ListView.ItemsSource to an ObservableCollection and then remove an item from that collection, then the associated renderers' Dispose method is not called. Only when the page is popped, then iOS disposes them, but Android and UWP do not. I did not check the other platforms.
Steps to Reproduce
- Create a ViewModel with an ObservableCollection
- Bind a ListView.ItemsSource to that collection
- Delete an item from the ObservableCollection
Expected Behavior
The renderers of all elements in the associated cell are disposed.
Actual Behavior
The Dispose method of those renderers is never called. I have to assume, that they are still in memory.
Basic Information
- Version with issue: tested with XF 3.0 up to 3.2-pre1
Reproduction Link
In the attached repro project I created a CustomLabel with a CustomLabelRenderer just to see when which methods are called. These classes only log, when the important methods are called and with which arguments, but otherwise don't change behavior. Both the SplashPage and the MainPage show the log of those method calls. Repro_MemoryLeak.zip