xamarin/Xamarin.Forms

Memory leak in ListView when deleting an item from the ItemsSource

オープン

#3,396 opened on 2018/07/25

 (17 件のコメント) (1 件のリアクション) (0 人の担当者)C# (1,926 件のフォーク)batch import
a/listviewe/3 :clock3:help wantedinactivep/Androidp/UWPp/iOS 🍎t/bug :bug:up-for-grabs

Repository metrics

Stars
 (5,644 個のスター)
PR merge metrics
 (30d に merged PR はありません)

説明

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

  1. Create a ViewModel with an ObservableCollection
  2. Bind a ListView.ItemsSource to that collection
  3. 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

コントリビューターガイド