Notice (2018-05-24): bugzilla.xamarin.com is now in
Please join us on
Visual Studio Developer Community and in the
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
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.
Issue originally posted at:
ListView is getting slower and slower with every refresh, probably due to a rendering/templating leak.
Solution is to set the CachingStrategyof my ListView to RecycleElement.
I'm encountering a rather concerning issue with a Vanilla ListView. When issuing a refresh command, I'm replacing the ListView's data source completely. This is fast in the beginning and then gets slower every time with the refresh indicator freezing. Even though I'm currently only returning five items, the refresh hangs towards a minute on the 5th repetition and then hangs basically forever or crashes the app.
Below is my code. Note that invoking the last two lines on the UI thread also didn't fix the problem:
List<Items> items= await rideService.FindRides(Ride.Id);
Items = items;
OnPropertyChanged(() => Items);
The problem seems to be with ItemTemplate- it contains a grid, a few bindings and converters. Nothing too serious. If I replace it with an empty template, the performance is ok. But still - it's just 5 items, which means a max of 30 templates in memory after 5 refreshes... There seems to be some seriously leaky behavior here.
Now: I could get around this by explicitly setting the CachingStrategyof my ListView to RecycleElement. This seems to further indicate that the hangs are produced by a leaky template rendering mechanism.
Which platform are you seeing this on? Also, if you could attach a repro, it's better.
Platform is Xamarin Forms. I don't have a repro right now, may be able to create one in the foreseeable future. Especially because the RecycleElement is buggy too: While it doesn't crash the app, Labels in recycled templates get truncated if they are being assigned longer strings.
Label with text "Ava", rendered
Then scrolling down, and a user called "Alexandra" gets rendered as "A.." even though there's plenty of space for the label.
Another observation: I have another listview, again with a bigger data template, and 4 items. Three of them are visible. I noticed that if I scroll just up and down, scrolling gets slower and slower until the up becomes unresponsive, if I don't set the CachingStrategy to "RecycleElement". So it appears it's not a memory leak as I assumed (because the refreshing used to kill the app), but smth else.
Thank you for taking the time to submit the bug. We tried to reproduce the issue you reported but were unable given the description. If you could please attach a reproduction to the bug by starting with a clean Xamarin.Forms project and adding just the code necessary to demonstrate the issue, we would very much appreciate it.
For your convenience, we have created some reproduction best practices viewable here: https://gist.github.com/jassmith/92405c300e54a01dcc6d
Xamarin Forms Team
I removed all ListView usages from my app and replaced them with a custom control that got rid of all the issues I had (which were tons). Sorry I can't help more...
@Philipp Sumi: Thank you for letting us know! I will close this report for now until we can get further information about it, since we can't know for sure if we've resolved it without a definitive test case to work against. Please feel free to reopen it later or submit another report if you encounter any further issues. Thank you again for your report!