Xamarin.forms: Android/UWP ListView Memory Leak

Created on 5 Mar 2019  路  5Comments  路  Source: xamarin/Xamarin.Forms

Description

When updating ItemsSource for ListView cell views remains in memory both on Android(not so fast) and UWP(rapidly)

Steps to Reproduce

  1. Run sample app in Android/UWP
  2. Click a few times on any item
  3. Check debug output or diagnostic on UWM

Expected Behavior

Cell Views GC

Actual Behavior

Cells grow in memory

Sample Project:
ListViewMemory.zip

listview performance 7 help wanted Android UWP bug up-for-grabs

Most helpful comment

This issue is a problem for me as well. I would be delighted if it is fixed.

All 5 comments

Allocation here. The debugger knows the source file and line for the frame's before the ctor but for some reason consider the symbols unloaded... So could also be a tooling issue. I'm in VS 2019.

image

I think UWP memory leaks with the Cells is related to this
https://github.com/xamarin/Xamarin.Forms/issues/5465

From what I can say some Cells never get Parent reset(after profiling my real app) and because they have a listener to Parent PropertyChanged (height) they keep everything(on Android) on UWP things even worse. Maybe use weak property listener in Cell to listen for Parent.PropertyChange will help (but this maybe workaround for a situation when Parent is not reset in the first place).
`protected override void OnParentSet()
{
if (RealParent != null)
{
RealParent.PropertyChanged += OnParentPropertyChanged;
RealParent.PropertyChanging += OnParentPropertyChanging;
}

        base.OnParentSet();

        PropertyPropagationController.PropagatePropertyChanged(null);
    }`

This issue is a problem for me as well. I would be delighted if it is fixed.

Is that still the case for collectionview? I use sflistview and it doesn't have this problem.

Was this page helpful?
0 / 5 - 0 ratings