-
Notifications
You must be signed in to change notification settings - Fork 1.9k
[Bug] UWP - ListView does not recycle cells [HUUGE MEMORY ISSUE] #10473
Comments
Update: We have a fairly complex app which uses listview to the max: |
…ring() to support frameworks such as ReactiveUI and the like
Finally somebody has found the root cause of UWP's ListView memory leaks! You absolute legend. Very much looking forward to these getting merged into master. Question: what tool is that in your screenshot which you are using for memory analysis? |
Well... don't be too happy. There is still some serious memory leaks, but we are currently not sure if they are within Xamarin.Forms for UWP or our own app We are using Jetbrains dotMemory. Since the 2020 release it is really a great tool - even shows you the instantiation path of some object instance. If you don't know Jetbrains - they are the brain behind the mother of tools: Resharper |
Is there any updates about that topic? I think gentledepp provided a solution for at least one of the memory leaks of the listview. We in our company still use that listview on a fairly large installation base. So we would appreciate that this fix would be merged, sine this solution is pending since end of April! |
Any update, seems like this was removed from 5.0.0. any idea when this will be fixed or are you providing another fix for this? |
I do not understand how such an important fix is pushed back further and further...
This really is a maintenance nightmare, but thankfully it is open source so you can do something about it. |
…ramatic leakage of memory when using a listview
xamarin#10473 - UWP - Fixed memoryleak in UWP CellControl causing a dramatic…
If there is a fix that @gentledepp has implemented that looks like it works and merged into their private fork of XF any chance one of the team @jsuarezruiz @samhouts @rmarinho etc can look at merging the same fix and resolve this MASSIVE memory issue that plagues the use of CollectionViews on the UWP platform.... |
Hi @CliffAgius i will ping @hartez he knows very well inner works of CollectionView. Thanks |
@rmarinho if you scroll up slightly you can see they merged a PR into thier own fork but have not done a PR into the XF Repo. If needed I'm happy to create the PR obviously attributing it to @gentledepp if it will speed things up. |
…o a XF PR. These have been tested and seem work solve the issue of the Cell not being disposed of as they are now reused rather than created from scratch. I am only putting forward the PR.
@rmarinho I have created a PR from @gentledepp work and having tested here it seems to work really well. Not sure if this will make it into XF5 or if it's going to get pushed in MAUI but a project I am working on really needs this so hopefully the former. I know there are other Issues based on the same fault that this could cross off as well. Let me know if you need anything else from me to push this along. |
…0473 * Update azure-pipelines.yml * Fix #10473 using changes made by @gentledepp but not subject to a XF PR. These have been tested and seem work solve the issue of the Cell not being disposed of as they are now reused rather than created from scratch. I am only putting forward the PR. * Changed the .yml file back to the current version not sure how or why it changed.... * Update azure-pipelines.yml * Update azure-pipelines.yml FIxed so that it's now reverted to the current live version of the file... * Update azure-pipelines.yml Co-authored-by: Rui Marinho <me@ruimarinho.net>
Description
On UWP, the viewcells of a listview are not recycled. Rather, every time the datacontext changes, a new cell is created from the datatemplate!
Steps to Reproduce
HeightRequest
of the viewcell to 80 or morector
of your ViewCellExpected Behavior
Constructor of the custom
ViewCell
should never be called during scrollingActual Behavior
Constructor is called all the time...
Basic Information
Screenshots
Reproduction Link
Workaround
Solution
We already found the issue for this.
The culprit is the
Xamarin.Forms.Platform.UAP.CellControl.SetCell(..)
method:The error is marked with a ⚠
Now we patched this ourselves like the following:
(We marked our additions with rockeds: 🚀)
This works like a charm.
I do not know where to target our PR though as there are so many versions affected.
Maybe you just copy paste the fix yourself in all platforms that apply?
@bruzkovsky @BrayanKhosravian - fyi ;-)
Update:
It seems that the CellControl has another memory leak:
The
Cell.PropertyChanged
event is not unsubscribed when the cell is unloadedWe'd fix it like this:
The text was updated successfully, but these errors were encountered: