Skip to content

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

Merged
jonathanpeppers merged 3 commits into
dotnet:mainfrom
jonathanpeppers:ModalPageLeaks
May 10, 2024
Merged

[ios/catalyst] fix memory leak in modal pages#22089
jonathanpeppers merged 3 commits into
dotnet:mainfrom
jonathanpeppers:ModalPageLeaks

Conversation

@jonathanpeppers

@jonathanpeppers jonathanpeppers commented Apr 26, 2024

Copy link
Copy Markdown
Member

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.

@jonathanpeppers jonathanpeppers added platform/ios perf/memory-leak 💦 Memory usage grows / objects live forever (sub: perf) labels Apr 26, 2024
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
@jonathanpeppers jonathanpeppers deleted the ModalPageLeaks branch May 10, 2024 13:34
@github-actions github-actions Bot locked and limited conversation to collaborators Jun 11, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Page-level memory leak on modal navigation on iOS

3 participants