Skip to content

Every MAUI Page generates a Memory Leak on iOS and macCatalyst #13520

@danardelean

Description

@danardelean

Description

On iOS and maccatalyst the finalizers are never called and I cannot understand if the page leaks or not.

I know that we use the interpretor (don't know if this could be the problem) but I would expect that at some point the instances that I have in memory should be cleaned.

Btw: How do we profile memory allocations in MAUI on iOS and maccatalyst? Xamarin. Profiler does not work for the MAUI applications.
I looked here:
https://github.com/dotnet/maui/wiki/Profiling-.NET-MAUI-Apps
but what I saw is how you profile startup not the memory allocations.

Any guidance on how to profile memory allocations on iOS, maccatalyst and Android?

Steps to Reproduce

1.Create a new MAUI project
2.Add a SecondPage and register with AppShell
3. For debugging add the finalizer on the SecondPage : ~SecondPage()
4. On MainPage add an toolbar item where you manually call GC.Collect()

Navigating back an forth and pressing the button that does garbage collector the finalizer is never called on iOS and maccatalyst (on Android the Finalizer it is called) so I don't understand if the page leak or not.

Link to public reproduction project repository

https://github.com/danardelean/MauiTestFinalizer

Version with bug

7.0 (current)

Last version that worked well

Unknown/Other

Affected platforms

iOS, macOS

Affected platform versions

iOS 16.3.1, macOS Ventura 13.2.1

Did you find any workaround?

NO

Relevant log output

No response

Metadata

Metadata

Labels

fixed-in-8.0.0-preview.3.8149Look for this fix in 8.0.0-preview.3.8149!legacy-area-perfStartup / Runtime performancep/1Work that is important, and has been scheduled for release in this or an upcoming sprintpartner/cat 😻this is an issue that impacts one of our partners or a customer our advisory team is engaged withperf/generalThe issue affects performance (runtime speed, memory usage, startup time, etc.) (sub: perf)perf/memory-leak 💦Memory usage grows / objects live forever (sub: perf)platform/iost/bugSomething isn't working

Type

No type
No fields configured for issues without a type.

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions