dotnet / maui

.NET MAUI is the .NET Multi-platform App UI, a framework for building native device applications spanning mobile, tablet, and desktop.
https://dot.net/maui
MIT License
22.04k stars 1.73k forks source link

Memory leak in collectionview #10007

Open pedromcrocha opened 2 years ago

pedromcrocha commented 2 years ago

Description

memory leak when in collectionview the ItemTemplate contains a control with a staticresource

Steps to Reproduce

use public reproduction project repository in android

click several times in test 1, see memory go up until a point

click several times in test 2, see memory go up until a point

click several times in test 3, see memory go up and up, and makes application unrespond

in windows test 2 , see memory go up and up

for test 1 xaml for CollectionView is

    <CollectionView
        x:Name="CollectionView1"
        Grid.Row="3"
        Grid.Column="0" />

for test 2 xaml for CollectionView is

    <CollectionView
        x:Name="CollectionView2"
        Grid.Row="3"
        Grid.Column="1">
        <CollectionView.ItemTemplate>
            <DataTemplate x:DataType="local:DataModel">
                <HorizontalStackLayout>
                    <Label Text="{Binding ID}" />
                    <Label Text="{Binding Name}" />
                    <Label Text="{Binding Data1}" />
                </HorizontalStackLayout>
            </DataTemplate>
        </CollectionView.ItemTemplate>
    </CollectionView>

for test 3 xaml for CollectionView is

    <CollectionView
        x:Name="CollectionView3"
        Grid.Row="3"
        Grid.Column="2">
        <CollectionView.ItemTemplate>
            <DataTemplate x:DataType="local:DataModel">
                <HorizontalStackLayout>
                    <Label
                        Background="{StaticResource SecondaryBrush}"
                        Text="{Binding ID}" />
                    <Label Text="{Binding Name}" />
                    <Label Text="{Binding Data1}" />
                </HorizontalStackLayout>
            </DataTemplate>
        </CollectionView.ItemTemplate>
    </CollectionView>

Link to public reproduction project repository

https://github.com/pedromcrocha/Maui_MemoryLeak

Version with bug

6.0.486 (current)

Last version that worked well

Unknown/Other

Affected platforms

Android, Windows, I was not able test on other platforms

Affected platform versions

android 9/12

Did you find any workaround?

No response

Relevant log output

No response

pedromcrocha commented 2 years ago

updated the repository project, to see the count of objects still alive

ghost commented 2 years ago

We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process.

ghost commented 1 year ago

Hi @pedromcrocha. We have added the "s/try-latest-version" label to this issue, which indicates that we'd like you to try and reproduce this issue on the latest available public version. This can happen because we think that this issue was fixed in a version that has just been released, or the information provided by you indicates that you might be working with an older version.

You can install the latest version by installing the latest Visual Studio (Preview) with the .NET MAUI workload installed. If the issue still persists, please let us know with any additional details and ideally a reproduction project provided through a GitHub repository.

This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.

Zhanglirong-Winnie commented 1 year ago

Verified this issue with Visual Studio 17.7.0 Preview 1.0. Not repro on windows and android platform with above project. Maui_MemoryLeak-master.zip Windows: Windows Android: Android

pedromcrocha commented 1 year ago

sorry, but, for what i see in your video, memory and object alive are still growing up.