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.28k stars 1.76k forks source link

Memory leak reloading list items on Windows #18030

Open sjorsmiltenburg opened 1 year ago

sjorsmiltenburg commented 1 year ago

Description

The most important problem I face with my app is that it keep increasing it's memory usage. At least one of the causes seem to be that my app has a collectionview that is bound to a grouped collection that needs it's items to be reset multiple times (every time you come back to the screen).

I'm using the latest 8.0.0-rc.9373

I have tried to make a test sample that illustrates the problem.

This is a screenshot of the memory increase of my own application, not the test application. image

Steps to Reproduce

start bugs project click on bug8 button keep pressing the reload button and watch memory increase.

Link to public reproduction project repository

https://github.com/sjorsmiltenburg/maui_bugs.git

Version with bug

7.0.96

Is this a regression from previous behavior?

Not sure, did not test other versions

Last version that worked well

8.0.0-rc.2.9373

Affected platforms

Windows

Affected platform versions

Windows

Did you find any workaround?

no

Relevant log output

No response

cgp1976 commented 1 year ago

I am having these issues as well and it's not only for collectionview. After ContentPage/ContentView loaded, basically adding/deleting/replacing control object will increase the memory and they don't drop till you quit the app.

use case - grid control step 1 - on the page, user click on button to add items (any child element) to the grid then remove all. setp 2 = repeat step 1 for sometimes and call GC.Collect().

Zhanglirong-Winnie commented 9 months ago

Verified this issue with Visual Studio 17.10.0 Preview 1. Can repro on windows platform with sample project. https://github.com/sjorsmiltenburg/maui_bugs.git image

sjorsmiltenburg commented 5 months ago

I have upgraded my sample project to use the latest net 9.0 preview and maui preview, but the memory leak still occurs