Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

[Bug] GroupHeaderTemplate leaks Memory #6761

Open
zeniya-takeshi opened this issue Jul 3, 2019 · 5 comments
Open

[Bug] GroupHeaderTemplate leaks Memory #6761

zeniya-takeshi opened this issue Jul 3, 2019 · 5 comments
Labels
a/listview Problems with the ListView/TableView a/performance e/3 🕒 3 help wanted We welcome community contributions to any issue, but these might be a good place to start! in-progress This issue has an associated pull request that may resolve it! p/iOS 🍎 t/bug 🐛 up-for-grabs We welcome community contributions to any issue, but these might be a good place to start!

Comments

@zeniya-takeshi
Copy link

Description

When I repeat that I add items to ListView with GroupHeaderTemplate and clear items,
GC.GetTotalMemory(true) is increasing.

Steps to Reproduce

  1. Create ListView with GroupHeaderTemplate
  2. Add items and clear items.
  3. Repeat "2.".

Expected Behavior

GC.GetTotalMemory(true) dosen't increase.

Actual Behavior

GC.GetTotalMemory(true) increases.

Basic Information

  • Version with issue: 4.1.0.555618
  • Last known good version: I don't know
  • IDE: Visual Studio 2019 Professional
  • Platform Target Frameworks:
    • iOS: 12.3.1
  • Nuget Packages:
  • Affected Devices:
    iPod touch 6

Screenshots

sorry for this isn't specified format
MomentAppCrashes.mp4.zip

Reproduction Link

MemoryTest.zip

@zeniya-takeshi zeniya-takeshi added s/unverified New report that has yet to be verified t/bug 🐛 labels Jul 3, 2019
@pauldipietro pauldipietro added this to New in Triage Jul 3, 2019
@samhouts samhouts added a/listview Problems with the ListView/TableView a/performance p/iOS 🍎 labels Jul 3, 2019
@jsuarezruiz
Copy link
Contributor

Very nice sample, thanks!. I have been doing several tests with it and effectively, using GroupHeaderTemplate leaks Memory.
I have tried without using groups and the memory remains stable (releases after certain seconds).

@jsuarezruiz jsuarezruiz removed the s/unverified New report that has yet to be verified label Jul 19, 2019
@jsuarezruiz jsuarezruiz moved this from New to Needs Estimate in Triage Jul 19, 2019
@samhouts samhouts added the e/3 🕒 3 label Jul 29, 2019
@samhouts samhouts moved this from Needs Estimate to Ready For Work in Triage Jul 29, 2019
@samhouts samhouts added this to To do in iOS Ready For Work Jul 30, 2019
@samhouts samhouts removed this from Ready For Work in Triage Jul 30, 2019
@SoniyaVarghese-1
Copy link

We are also facing the memory leaks in group header template. In our scenario we have binding the custom views in this template and clearing this in view disappearing but the application memory is not getting deallocated even when the page is removed from the view.Please let us know which version of the xamarin forms have this fix

@samhouts samhouts added inactive Issue is older than 6 months and needs to be retested help wanted We welcome community contributions to any issue, but these might be a good place to start! up-for-grabs We welcome community contributions to any issue, but these might be a good place to start! and removed inactive Issue is older than 6 months and needs to be retested help wanted We welcome community contributions to any issue, but these might be a good place to start! labels Jul 17, 2020
@samhouts samhouts added this to the 5.0.0 milestone Aug 13, 2020
@samhouts samhouts added this to To do in vNext+1 (5.0.0) Aug 14, 2020
@samhouts samhouts added inactive Issue is older than 6 months and needs to be retested help wanted We welcome community contributions to any issue, but these might be a good place to start! and removed inactive Issue is older than 6 months and needs to be retested labels Sep 18, 2020
@t-johnson
Copy link
Contributor

t-johnson commented Oct 15, 2020

I am working on a fix for this one also.
One thing I have found is the TemplatedItemsList<TView, TItem>.GroupedReset function is merely clearing the _templatedObjects list, without unhooking each item.
Calling UnhookAndClear instead should fix this.
This does appear to solve some of the memory leak but not all of it...

@t-johnson
Copy link
Contributor

Curious finding - simply having a listview showing a bunch of empty groups, just scrolling the list up and down many times causes memory to skyrocket.

@t-johnson
Copy link
Contributor

I've got a working solution now that removes pretty much all memory leaks when using ListView that has any kind of group header. Formalizing it and will do a PR shortly.

t-johnson pushed a commit to t-johnson/Xamarin.Forms that referenced this issue Oct 20, 2020
…ers.

TemplatedItemsList: Ensure items are unhooked correctly when removing them, whether as individual removals or list resets.  Without this, the native cells do not actually get removed.
CellTableViewCell: use event PropertyChangedEventHandler instead of action (seems more standard)
TextCellRenderer: Correct the event delegate hookup
ListViewRenderer: Actually re-use the UITableViewCell when creating header sections, otherwise we endlessly create new ones, leaving the old ones alive through event handlers
t-johnson pushed a commit to t-johnson/Xamarin.Forms that referenced this issue Oct 20, 2020
t-johnson pushed a commit to t-johnson/Xamarin.Forms that referenced this issue Oct 20, 2020
t-johnson pushed a commit to t-johnson/Xamarin.Forms that referenced this issue Oct 20, 2020
@samhouts samhouts removed this from the 5.0.0 milestone Nov 2, 2020
@samhouts samhouts added the in-progress This issue has an associated pull request that may resolve it! label Nov 2, 2020
@samhouts samhouts moved this from To do to In progress in iOS Ready For Work Nov 3, 2020
@samhouts samhouts added this to In Progress in vNext+1 (5.0.0) Nov 3, 2020
@PureWeen PureWeen added this to To do in v5.0.1 via automation Nov 5, 2020
@PureWeen PureWeen removed this from In Progress in vNext+1 (5.0.0) Nov 5, 2020
@samhouts samhouts added this to In Progress in vNext+1 (5.0.0) Nov 5, 2020
@samhouts samhouts removed this from To do in v5.0.1 Nov 5, 2020
@PureWeen PureWeen added this to To do in v5.0.1 via automation Nov 5, 2020
@PureWeen PureWeen removed this from In Progress in vNext+1 (5.0.0) Nov 5, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
a/listview Problems with the ListView/TableView a/performance e/3 🕒 3 help wanted We welcome community contributions to any issue, but these might be a good place to start! in-progress This issue has an associated pull request that may resolve it! p/iOS 🍎 t/bug 🐛 up-for-grabs We welcome community contributions to any issue, but these might be a good place to start!
Projects
iOS Ready For Work
  
In progress
v5.0.1
To do
Development

Successfully merging a pull request may close this issue.

5 participants