xamarin/Xamarin.Forms

[UWP] ListView with ViewCells Still Leaks Memory

オープン

#3,339 opened on 2018/07/19

 (2 件のコメント) (1 件のリアクション) (0 人の担当者)C# (1,926 件のフォーク)batch import
a/listviewe/6 :clock6:help wantedin-progressinactivep/UWPpartner/cat 😻t/bug :bug:up-for-grabs

Repository metrics

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

説明

Description

I am using a ListView to display a list of a fixed maximum size, where I only swap out elements (in the list). (Removing the oldest / highest index, to insert a new element at index 0.) I am using ViewCell via DataTemplate. Simple observation: The longer it runs, the more memory the process consumes. Growth is steeper the more complex the view is. Workaround: If I add a handler to the cell.Disappearing event which nulls the view (cell.View = null), memory doesn’t really seem to leak anymore. So it would seem that mainly my view is being leaked, and via the ViewCell.

Steps to Reproduce

  1. Build ViewCell of relatively complex layout, so instances use a noticeable chunk of memory
  2. Keep adding fresh instances of this ViewCell to a ListView, and remove them again
  3. Watch memory consumption grow indefinitely

Expected Behavior

If size of elements in the ListView stays constant, consumed memory should also stay roughly constant.

Actual Behavior

Memory consumption keeps growing.

Basic Information

  • Version with issue: Latest (3.1.0 Service Release 1)
  • Last known good version: Not sure, UWP ListView memleaks have been around for a while
  • IDE:
  • Platform Target Frameworks:
    • UWP: 16299
  • Affected Devices: Windows 10 PC

Reproduction Link

UwListViewLeak.zip

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