Skip to content

Memory leak when scrolling a CollectionView with IsGrouped=true #17698

Description

@tranb3r

Description

On android with net8-rc.1, I'm comparing the memory usage of a CollectionView with or without IsGrouped.
When scrolling a CollectionView with IsGrouped=true, the memory usage increases infinitely.
When scrolling a CollectionView with IsGrouped=false, the memory usage is stable.

Steps to Reproduce

  1. Open repro project
  2. On the first tab, tap on Add button, it will create a CollectionView with IsGrouped=false.
  3. Scroll the CollectionView up and down. Observe memory usage with dotnet-gcdump. It is stable.
  4. On the second tab, tap on Add button, it will create a CollectionView with IsGrouped=true.
  5. Scroll the CollectionView up and down. Observe memory usage with dotnet-gcdump. It is slowly increasing.
  6. Alternatively, open the attached gcdump files I've captured when scrolling the second tab. Between the first (memory-12.gcdump) and second (memory-19.gcdump), the size diff is +144,688 for object type List<Microsoft.Maui.Controls.Element>.

gcdump.zip

Screenshot 2023-09-27 173020

Link to public reproduction project repository

https://github.com/tranb3r/Issues/tree/main/MauiAppCollectionViewGroupingLeak

Version with bug

8.0.0-rc.1.9171

Is this a regression from previous behavior?

Not sure, did not test other versions

Last version that worked well

Unknown/Other

Affected platforms

Android

Affected platform versions

Android 34

Did you find any workaround?

No workaround

Relevant log output

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-controls-collectionviewCollectionView, CarouselView, IndicatorViewmigration-compatibilityXamarin.Forms to .NET MAUI Migration, Upgrade Assistant, Try-Convertperf/generalThe issue affects performance (runtime speed, memory usage, startup time, etc.) (sub: perf)perf/memory-leak 💦Memory usage grows / objects live forever (sub: perf)platform/androidt/bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions