question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Massive memory leak in CollectionView while scrolling

See original GitHub issue

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

  1. Load the repository and run the example.
  2. Scroll up and down in the CollectionView.
  3. 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

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:14
  • Comments:9 (2 by maintainers)

github_iconTop GitHub Comments

5reactions
jonathanpepperscommented, Feb 16, 2023

I’ve been testing memory leak issues with this app.

These should fix this:

(I marked the last one to close this when merged)

5reactions
HausBJBcommented, 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

Read more comments on GitHub >

github_iconTop Results From Across the Web

ios - How to avoid the memory issue while scrolling an ...
I'm displaying lot of images (5k images) in UICollectionView . These images has been download from remote server. When I scroll from top...
Read more >
Memory leak in ListView when the ItemsSource has changed
Note: It is possible the memory leak is caused by the bindings holding objects longer than necessary. Similar memory leaks can be reproduced ......
Read more >
Experiencing memory leak using UICollectionView and ...
In one of my views, I use UICollectionView to display album art for all albums in the library. When scrolling I'm getting huge...
Read more >
The Most Common Issues I've Caught Reviewing iOS Apps
If you need something other than a vertically scrolling list of rows, a collection view covers those other cases. They are extremely memory...
Read more >
UIDragItem causes memory leak when…
I have a CollectionView with Drag and Drop and Context Menu functionality. There's a memory leak caused by returned [UIDragItem] array in ItemsForBeginning ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found