xamarin/Xamarin.Forms

Memory leak in ListView when deleting an item from the ItemsSource

开放

#3,396 创建于 2018年7月25日

 (17 条评论) (1 个反应) (0 位负责人)C# (1,926 个派生)batch import
a/listviewe/3 :clock3:help wantedinactivep/Androidp/UWPp/iOS 🍎t/bug :bug:up-for-grabs

仓库指标

星标
 (5,644 个星标)
PR 合并指标
 (30 天内没有已合并 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

贡献者指南