Skip to content

Page-level memory leak in NavigationPage on iOS #20119

@AdamEssenmacher

Description

@AdamEssenmacher

Description

NavigationPages are on iOS are not garbage collected after being removed.

Page-level leaks are serious, as they prevent child elements (in this case, whole child pages) from being collected as well.

Steps to Reproduce

  1. Set Application.Current.MainPage to a NavigationPage
  2. Swap Application.Current.MainPage with a different page
  3. Force GC runs
  4. Observe navigation page (and its children) never collected

Link to public reproduction project repository

https://github.com/AdamEssenmacher/iOSNavigationPageLeak.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

Affected platform versions

iOS 17.2

Did you find any workaround?

Calling DisconnectHandler() on the NavigationPage's Handler before removing it from use will prevent the navigation page and its children from leaking.

Relevant log output

No response

Metadata

Metadata

Labels

area-navigationNavigationPagedelighter-scfixed-in-8.0.60fixed-in-9.0.0-preview.6.24327.7partner/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/ioss/triagedIssue has been revieweds/verifiedVerified / Reproducible Issue ready for Engineering Triaget/bugSomething isn't working

Type

No type
No fields configured for issues without a type.

Projects

Status

Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions