[UWP] ListView with ViewCells Still Leaks Memory
#3,339 opened on Jul 19, 2018
Repository metrics
- Stars
- (5,644 stars)
- PR merge metrics
- (No merged PRs in 30d)
Description
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
- Build
ViewCellof relatively complex layout, so instances use a noticeable chunk of memory - Keep adding fresh instances of this
ViewCellto aListView, and remove them again - 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