Repository navigation
Closed
Labels
area-controls-collectionviewCollectionView, CarouselView, IndicatorViewfixed-in-8.0.0-preview.1.7762Look for this fix in 8.0.0-preview.1.7762!p/1Work that is important, and has been scheduled for release in this or an upcoming sprintperf/generalThe issue affects performance (runtime speed, memory usage, startup time, etc.) (sub: perf)platform/androidplatform/windowst/bugSomething isn't working
Milestone
Description
Description
Scrolling through items in CollectionView leads to massive memory leak if the DataTemplate has Grid/VerticalStackLayout/HorizontalStackLayout as its first children. Wrapping the layout inside a Border solves the issue.
DataTemplate causing the issue:
<CollectionView.ItemTemplate>
<DataTemplate>
<HorizontalStackLayout>
<Label Text="{Binding .}" />
</HorizontalStackLayout>
</DataTemplate>
</CollectionView.ItemTemplate>
DataTemplate solving the issue:
<CollectionView.ItemTemplate>
<DataTemplate>
<Border>
<HorizontalStackLayout>
<Label Text="{Binding .}" />
</HorizontalStackLayout>
</Border>
</DataTemplate>
</CollectionView.ItemTemplate>
- Speed of scrolling doesn't seem to affect the issue.
- GC is getting triggered, but the memory keeps going up infinitely in spite.
- The memory leak is really significant and makes the app unusable very quickly.
- Attached repository is 7.0.0-rc.1.6683, but I had the same problem in 6.0.x.
- Android was tested only on Windows Subsystem for Android and the problem seems to be the same.
Steps to Reproduce
- Load the repository and run the example.
- Scroll up and down in the CollectionView.
- Watch the memory usage in ResMon/memory profiler.
Link to public reproduction project repository
https://github.com/Vroomer/MAUI-CollectionView-memory-leak.git
Version with bug
Unknown/Other (please specify)
Last version that worked well
Unknown/Other
Affected platforms
Android, Windows, I was not able test on other platforms
Affected platform versions
Windows SDK 10.0.22000, Windows subsystem for Android 2207.40000.8.0
Did you find any workaround?
Wrapping DataTemplate's layout children inside Border solves the issue.
Relevant log output
No response
Reacted by Γngel RubΓ©n, ksemenenko, Casperbart, Brandon Minnick, Matthieu Barthelemy, Radek VymΔtalΓk, Alex Monahan, Espen RΓΈvik Larsen, feal87, Kacper Tryniecki and 4 more
Metadata
Metadata
Assignees
Labels
area-controls-collectionviewCollectionView, CarouselView, IndicatorViewfixed-in-8.0.0-preview.1.7762Look for this fix in 8.0.0-preview.1.7762!p/1Work that is important, and has been scheduled for release in this or an upcoming sprintperf/generalThe issue affects performance (runtime speed, memory usage, startup time, etc.) (sub: perf)platform/androidplatform/windowst/bugSomething isn't working
Activity
HausBJB commentedon Oct 29, 2022
Hello, is there any news? These are things that should be in as soon as possible. Every app has lists and how can you expect to publish an app with such a performance.
Thanks
Majestic-Mustang commentedon Dec 10, 2022
Any update on this?
mlancione commentedon Dec 12, 2022
Any update from MS on this? Seems like a serious issue with a basic control.
LennoxP90 commentedon Dec 12, 2022
wrapping in border didn't solve my issue (performance)
I noticed you are not using compiled bindings either which I am
7 remaining items
[core] fix memory leaks in bindings (dotnet#13327)
JanZeman commentedon Feb 24, 2023
Hello @jonathanpeppers, thank you very much for your recent memory leaks fixes! It is very encouraging to see someone tries to attack those (seems to be mid-, long-term) problems. I observed memory leaks in CollectionView / ObservableCollection scenario not only during the scrolling but also when modifying the ObservableCollection content or assigning a new ObservableCollection to the existing CollectionView. Being MAUI hobbyist I was not sure I did everything perfectly so I tried to analyze some MAUI tutorials I found on YouTube and I was able to reproduce there as well. This is one of them: Memory leak on every search executed which is a fork of this one. Do I understand correctly that your recent changes might have fixed this kind of memory leaks as well?
jonathanpeppers commentedon Feb 24, 2023
@JanZeman your issue looks like this one: #13530
I want to investigate a bit more to understand why it only happens on Windows, but we should get this one in soon.
JanZeman commentedon Feb 25, 2023
@jonathanpeppers Yes, that looks way closer to mine issue. Out of curiosity I will try to understand more there. Thank you!