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
21.63k stars 1.61k forks source link

Memory usage increases when scrolling collectionview if resources count is more than 191 #22053

Open tranb3r opened 2 weeks ago

tranb3r commented 2 weeks ago

Description

I have a simple maui application for android with a collectionview and several static resources. The collectionview is NOT using the static resources. Here is a strange behavior that happens when scrolling the collectionview:

It's very easy to reproduce. Same behavior for both Debug and Release.

ok.webm ko.webm

Steps to Reproduce

  1. Open repro and launch the app on android emulator (Pixel 5).
  2. The resources count should be 191. Scroll the collectionView. Memory usage increases.
  3. Reset memory by clicking the GC button. Memory goes back to its inital value.
  4. Decrease the resources count to 190. Scroll the collectionView. Memory usage is stable.

Link to public reproduction project repository

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

Version with bug

8.0.21 SR4.1

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

No response

Did you find any workaround?

No workaround.

Relevant log output

No response

kevinxufei commented 2 weeks ago

Can repro this issue at Android platform at the latest 17.10 Preview 5 (8.0.3/8.0.21), and a smaller resources count also results in an increase in memory usage.

tranb3r commented 2 weeks ago

@kevinxufei I'm suprised you also get the issue with only 90 resources. Did you run the app in Release? In Debug, you'd have to disable HotReload.

kevinxufei commented 2 weeks ago

The previous result did not disable 'HotReload'. If resources count>190, memory usage increases. If resources count<190, memory usage is stable.Thanks for reminding!