Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ios/catalyst] fix memory leak in modal pages #22089

Merged
merged 3 commits into from May 10, 2024

Conversation

jonathanpeppers
Copy link
Member

@jonathanpeppers jonathanpeppers commented Apr 26, 2024

Fixes: #20094
Context: https://github.com/AdamEssenmacher/iOSModalLeak.Maui

In the above sample, you can see that modal Page's on iOS or Catalyst live forever after they are dismissed. I was able to reproduce this issue in a device test.

After some investigation, the ContainerViewController appears to have a cycle:

  • ContainerViewController -> IElement? _view; -> PageHandler -> ContainerViewController

After 7d0af63 was merged, this works fine when using NavigationPage, but not when using modals.

It appears after solving the cycle, the ContainerViewController goes away as well as the PageHandler and the Page.

Fixes: dotnet#20094
Context: https://github.com/AdamEssenmacher/iOSModalLeak.Maui

In the above sample, you can see that modal `Page`'s on iOS or Catalyst
live forever after they are dismissed. I was able to reproduce this
issue in a device test.

After some investigation, the `ContainerViewController` appears to have
a cycle:

* `ContainerViewController` -> `IElement? _view;` -> `PageHandler` -> `ContainerViewController

After 7d0af63 was merged, this works fine when using `NavigationPage`,
but not when using modals.

It appears after solving the cycle, the `ContainerViewController` goes
away as well as the `PageHandler` and the `Page`.
@jonathanpeppers jonathanpeppers marked this pull request as ready for review May 7, 2024 16:10
@jonathanpeppers jonathanpeppers requested a review from a team as a code owner May 7, 2024 16:10
@jonathanpeppers jonathanpeppers merged commit 7076514 into dotnet:main May 10, 2024
49 checks passed
@jonathanpeppers jonathanpeppers deleted the ModalPageLeaks branch May 10, 2024 13:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
memory-leak 💦 Memory usage grows / objects live forever platform/iOS 🍎
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Page-level memory leak on modal navigation on iOS
2 participants