Bug 31264 - ListView seems to be keeping references around when used in conjunction with ObservableCollection
Summary: ListView seems to be keeping references around when used in conjunction with ...
Status: RESOLVED FIXED
Alias: None
Product: Forms
Classification: Xamarin
Component: Forms ()
Version: 1.4.3
Hardware: Macintosh Mac OS
: Normal normal
Target Milestone: ---
Assignee: Eric Maupin
URL:
Depends on:
Blocks:
 
Reported: 2015-06-19 19:16 UTC by Rob DeRosa
Modified: 2016-04-10 02:04 UTC (History)
5 users (show)

Tags: AC
Is this bug a regression?: ---
Last known good build:


Attachments
Heapshot results (10.63 KB, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet)
2015-06-19 19:16 UTC, Rob DeRosa
Details
Sample project (151.36 KB, application/zip)
2015-06-19 19:17 UTC, Rob DeRosa
Details


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FIXED

Description Rob DeRosa 2015-06-19 19:16:46 UTC
Created attachment 11692 [details]
Heapshot results

A customer is reporting that when updating the OC bound to a ListView that references to certain objects are never dereferenced. Below are his comments and attached is a sample application that exhibits this behavior as well as the results from his heapshot analysis.

Attempted on: 1.4.2.6359 and with 1.4.3.6364-pre3

"I ran the app using the Mono Heapshot tool and cycled through the even, odd, and all filters once. Then I went through several iterations where I would capture a snapshot and then cycle through the filters. I ended up with five heap snapshots. I used the tool to compare the delta of the number of instance of types between successive snapshots. I would expect the number of instances between snapshots to be roughly the same, especially since I modified the code to call CG.Collect() each time the filter changed.
 
However, I see that the number of instances of several types is increasing without bound, implying that there is a memory leak. This may be related to the memory leak that you alluded to in your previous e-mail, but I wanted you to have the information that we gathered in case it was helpful. I have attached a spreadsheet that shows the information I collected. Note that the numbers in each column represent the increase in the number of instances between two snapshots, not the absolute number of instances (which is much greater).
 
Given the types that are leaking, our suspicion is that the way we are reusing the view model when the filter changes is somehow causing Xamarin.Forms to not unregister event handlers when they are no longer needed and re-register them multiple times on the same objects. If this is true, then when something like a property change event is raised, it would fire many times, chewing up CPU time. This might explain some of the slowdown we are seeing."

This is similar to https://bugzilla.xamarin.com/show_bug.cgi?id=30678 but in this case the items within the OC are being replaced vs replacing the entire list.
Comment 3 Jason Smith [MSFT] 2016-04-10 02:04:18 UTC
Thank you for taking the time to submit this report. After reviewing the description of this bug, we believe it no longer affects the current version of Xamarin.Forms. If you are still experiencing the issue after updating your packages, please reopen this report with an attached reproduction.
 
For your convenience, we have created some reproduction best practices viewable here: https://gist.github.com/jassmith/92405c300e54a01dcc6d

Warm regards,
Xamarin Forms Team