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

Fix Memory leak on Popup #1398

Merged
merged 4 commits into from
Sep 23, 2023
Merged

Fix Memory leak on Popup #1398

merged 4 commits into from
Sep 23, 2023

Conversation

pictos
Copy link
Member

@pictos pictos commented Sep 10, 2023

Description of Change

This PR null the Popup.Parent to prevent memory leaks, it will mostly occur when the parent is a MainPage (root page) or Shell.

Probably, you may think "Wait, but .NET MAUI doesn't handle that internally?", yeah it does but for VisualElement , Popup is an Element and doesn't get all this love, so we need to do that by ourselves. :/

Linked Issues

PR Checklist

Additional information

Before:
You see the CustomPopup holding on memory.
image

After:
No more references to it, YaY:
image

@pictos pictos requested a review from a team September 10, 2023 02:05
Both `CloseAsync(object)` and `OnDismissedByTappingOutsideOfPopup()` `await` the `OnClosed(object, bool)` method.

We can just set the Parent reference to `null` in `OnClosed(object,bool)` and remove the now unused field.
brminnick
brminnick previously approved these changes Sep 23, 2023
@brminnick brminnick merged commit 322547e into main Sep 23, 2023
7 checks passed
@brminnick brminnick deleted the pj/fix-memory-leak-on-popup branch September 23, 2023 19:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Potential Memory Leak when using Popup
3 participants