-
Notifications
You must be signed in to change notification settings - Fork 424
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
[BUG] MediaElement is not currently being Garbage Collected #1702
Comments
Hey @marco-skizza! This doesn't fix the bug, but there's a workaround where you should disconnect the handler when you're done using MediaElement to avoid memory leaks. Here's a PR we recently merged that demonstrates how we're now doing this work-around in the SampleApp: @bijington - Do we have anything in our docs to note this? We totally should! |
Thanks for your feedback @brminnick I'm already disposing the handler. But even though I'm disconnecting the handler, the |
@marco-skizza what's happening? |
@pictos I try to explain... I just updated my sample project.
I hope this makes any sense... |
Hey @marco-skizza! After some refactoring, I was able to trigger the finalizer in I've opened a Pull Request to your sample reproduction: marco-skizza/CommunityMauiMediaElement#1 This fork contains the updated sample. To trigger the disposal of ![]() |
Notes from the Pull Request: I played around with your code a bit and found out that it starts "leaking" again when you add the It may be a similar problem as: dotnet/maui#20710 |
Hi @brminnick After playing around with your code some more I found out the following: Your code seems to work, because you have a source binding I hope you can look at this when time allows. Many Thanks! |
Hi @brminnick It seems - at least on iOS - that besides disconnecting the handler, one has to dispose the MyMediaElement.Handler?.DisconnectHandler();
MyMediaElement.Dispose(); This fixed the Memory Leak for me - together with the fix above. I'll open a PR when I tested this some more... |
Co-authored-by: Marco Finschi <[email protected]>
Is there an existing issue for this?
Did you read the "Reporting a bug" section on Contributing file?
Current Behavior
As it seems, the
MediaElement
doesn't ever get Garbage Collected.Expected Behavior
The
MediaElement
should get Garbage Collected eventually, and with it the containing page.Steps To Reproduce
MediaElement
and navigate back~MyPage()
never gets calledLink to public reproduction project repository
https://github.com/marco-skizza/CommunityMauiMediaElement
Environment
Anything else?
Thanks for looking at this!
The text was updated successfully, but these errors were encountered: