maui icon indicating copy to clipboard operation
maui copied to clipboard

Cascading memory leak when StrokeShape is set via a global style on Border control

Open AdamEssenmacher opened this issue 2 years ago • 3 comments

Description

Setting the StrokeShape property on a Border control via a global style results in the control and its containing page to leak.

Page-level leaks are serious, as they prevent child elements from being collected as well.

It's also noteworthy that the OOTB MAUI template creates a global Border style with the StrokeShape set, so all MAUI apps created with the standard solution template will have this page-level cascading leak unless the global style is removed or StrokeShape is explicitly set.

I recommend the area/perf label for the issue.

Also, I'm guessing this applies to iOS as well as Android. However, iOS currently leaks no matter how the StrokeShape property is set, so it can't be properly tested.

Steps to Reproduce

  1. Create MAUI app using standard template
  2. Push/pop page containing a Border control
  3. Force GC
  4. Observe leak
  5. Push/pop page containing a Border control with StrokeShape property explicitly set
  6. Force GC
  7. Observe no leak

Link to public reproduction project repository

https://github.com/AdamEssenmacher/BorderStyleLeak.Maui

Version with bug

8.0.3

Is this a regression from previous behavior?

Not sure, did not test other versions

Last version that worked well

Unknown/Other

Affected platforms

iOS, Android

Affected platform versions

No response

Did you find any workaround?

No response

Relevant log output

No response

AdamEssenmacher avatar Jan 25 '24 21:01 AdamEssenmacher

We've added this issue to our backlog, and we will work to address it as time and resources allow. If you have any additional information or questions about this issue, please leave a comment. For additional info about issue management, please read our Triage Process.

ghost avatar Jan 26 '24 15:01 ghost

This is probably a kind-of duplicate of this for which I already proposed a couple of solutions and a temporary workaround: #18925

albyrock87 avatar Jan 26 '24 16:01 albyrock87

@albyrock87 I think they're related but our complaints are distinct. Your issue is focused on loading performance, while this one is specifically focused on garbage collection / memory leakage.

Both issues have a common cause in a global shared reference, and might have a shared fix.

AdamEssenmacher avatar Jan 26 '24 18:01 AdamEssenmacher

Seeing the same issue on 8.0.14. Any timeline for a fix?

@AdamEssenmacher Thanks for MemoryToolkit ;-) Helped a lot to identify issues

Larhei avatar Mar 22 '24 15:03 Larhei

Appears to be fixed in 8.0.40-nightly.10455

AdamEssenmacher avatar Apr 09 '24 15:04 AdamEssenmacher

Thanks! Fix was:

  • https://github.com/dotnet/maui/pull/21151

jonathanpeppers avatar Apr 09 '24 17:04 jonathanpeppers

@jonathanpeppers please also look at my comment here: https://github.com/dotnet/maui/issues/18925#issuecomment-1824058832

Number 1 is still an issue even if the leak has been fixed.

albyrock87 avatar Apr 09 '24 18:04 albyrock87