This repository has been archived by the owner on May 1, 2024. It is now read-only.
[Bug] ListView with HasUnevenRows="True" is leaking memory (items) #10820
Labels
a/listview
Problems with the ListView/TableView
a/performance
e/5 🕔
5
in-progress
This issue has an associated pull request that may resolve it!
p/iOS 🍎
partner/cat 😻
t/bug 🐛
Description
ListView with HasUnevenRows="True" somehow retains items bound to the list view in memory even after full data reload. Basically every reload dumps old entries and creates new items, but old items don’t go away. I was troubleshooting it, trying to find, what exactly retains the entries and found one particular line which caused that: HasUnevenRows="True". Having that information I recreated a sample solution and was able to reproduce the issue by adding that line to my simple ListView with a simple data binding to an ObservableCollection. The number of retained items in memory depends on the Grouping flag, if enabled then all items are retained, if disabled, only 1 per each refresh cycle is retained in memory.
Additional tests
ItemSizingStrategy= MeasureAllItems
)Steps to Reproduce
MyTestItem
class, mark only live objects and observe that no all of them are garbage collectedExpected Behavior
Only items currently bound to the listview stay in memory
Actual Behavior
Some of the items are retained in memory. If you enabled grouping then ALL items will be retained.
Basic Information
Screenshots
Reproduction Link
The sample project is here (master branch):
https://github.com/alexeystrakh/xamarinforms-listview-memoryleak
There are a few additional tests with grouping enabled in a separate branch:
https://github.com/alexeystrakh/xamarinforms-listview-memoryleak/tree/master-leak-with-grouping
And navigation which frees the ListView:
https://github.com/alexeystrakh/xamarinforms-listview-memoryleak/tree/master-leak-with-navigation
Workaround
If the page which holds the listview is a root page, there is no workaround, but if the page is a details page, closing that page will let the listview go, which in turn lets all the retained items go.
The text was updated successfully, but these errors were encountered: