This repository has been archived by the owner on May 1, 2024. It is now read-only.
[Bug] ListView(Adapter) is leaking memory (Cells and their Native Views) and causes ObjectDisposed exception for custom cells that properly implement dispose for their native view. #9721
Labels
a/listview
Problems with the ListView/TableView
a/performance
i/high
Completely doesn't work, crashes, or is unusably slow, has no obvious workaround; occurs less often
p/Android
t/bug 🐛
Projects
Description
Listview(Adapter) is leaking memory (Cells and their Native Views) and causes ObjectDisposed exception for custom cells that properly implement dispose for their native view.
Steps to Reproduce
I supplied a minimal project to reproduce this using the TextCell, TextCell1 is the same as provided by forms, TextCell2 implements dispose properly.
Navigate back and forth using the Test1 button this will fire OnCellPropertyChanged as may times as you navigated back and forth.
Navigate back and forth using the Test2 button this will throw a ObjectDisposed exception the second time you press the Test2 button.
Expected Behavior
OnCellPropertyChanged shouldn't be called at all and no ObjectDisposed exception should be thrown. The Listview(Adapter) should properly release its cells by clearing the bindingcontext and the native view for the cell should dispose its native child views.
Actual Behavior
The Listview(Adapter) isn't clearing the bindingcontext for the cells, which causes the cells to hang around (leak memory) and get notified of changes in the viewmodel, which causes OnCellPropertyChanged to be called on (old) none visual cells. The current implementation seems to be working because the child views of the native view for the cells aren't properly disposing of their child views (which also causes memory leaks) and still update (old) none visual native views.
Basic Information
Forms: V4.3.0.908675 (But probably effects all versions).
Platforms: Android (didn't test other platforms, but the same problem likely exists).
Reproduction Link
App14.zip
The text was updated successfully, but these errors were encountered: