roubachof / Sharpnado.CollectionView

A performant list view supporting: grid, horizontal and vertical layout, drag and drop, and reveal animations.
The Unlicense
245 stars 30 forks source link

Memory Leak in CollectionView #56

Closed jtorvald closed 9 months ago

jtorvald commented 2 years ago

Describe the bug When I have the sho:CollectionView in a detail page and I navigate to it and back (repeat). The page count of the detail page is increasing. When I remove the sho:CollectionView from the page the detail page gets garbage collected as expected.

I haven't been able to drill it down into the control but I managed to reproduce it with a minimal XAML without events:

To Reproduce

                        <sho:CollectionView 
                                CollectionLayout="Horizontal"
                                ItemsSource="{Binding MediaFiles}"
                                SnapStyle="Start">

                            <sho:CollectionView.ItemTemplate>
                                <DataTemplate  x:DataType="models:Media">
                                    <ViewCell>
                                        <Label Text="{Binding Url}"/>
                                    </ViewCell>
                                </DataTemplate>
                            </sho:CollectionView.ItemTemplate>
                        </sho:CollectionView>

Platform:

=== Xamarin.Profiler ===

Version: 1.6.15.68 Location: /Applications/Xamarin Profiler.app/Contents/MacOS/Xamarin Profiler

=== Apple Developer Tools ===

Xcode 13.2.1 (19586) Build 13C100

Version: 12.0.0.3 (Visual Studio Enterprise) Commit: xamarin-android/d16-11/f0e3c2d Android SDK: /Users/developer/Library/Developer/Xamarin/android-sdk-macosx Supported Android versions: 8.0 (API level 26) 8.1 (API level 27)

SDK Tools Version: 26.1.1 SDK Platform Tools Version: 30.0.5 SDK Build Tools Version: 31.0.0

=== Xamarin.iOS ===

Version: 15.4.0.0 (Visual Studio Enterprise) Hash: 8fc41ae82 Branch: xcode13.2 Build date: 2021-12-09 01:07:56-0500

=== Operating System ===

Mac OS X 12.2.0

jtorvald commented 2 years ago

Here a screenrecording with the Sample App https://user-images.githubusercontent.com/1808131/151874472-00b23ca3-f161-4138-8f49-b0110e4c40f9.mp4

roubachof commented 2 years ago

I tried to add a WeakReference that was maybe(?) missing.

jtorvald commented 2 years ago

I've tried the latest code but it still has a memory leak somewhere. The same issue, going to GridPage and back increases the number of live GridPages. I haven't managed to track it down yet since I'm a bit short in time.

AdamEssenmacher commented 9 months ago

The linked PR will fix the issue for MAUI only.