CommunityToolkit / CommunityToolkit/Maui
[BUG] Potential memory leak in MediaElement on Windows
- Dominant language
- C#
- Stars
- 2.7k
- Forks
- 500
- Avg merge
- 2d 14h
- Merged PRs (30d)
- 7
Description
### Is there an existing issue for this?
- [x] I have searched the existing issues
### Did you read the "Reporting a bug" section on Contributing file?
- [x] I have read the "Reporting a bug" section on Contributing file: https://github.com/CommunityToolkit/Maui/blob/main/CONTRIBUTING.md#reporting-a-bug
### Current Behavior
It appears that not all event handlers are disconnected correctly from the MediaElement when it is used on Windows.
### Expected Behavior
All handlers are disconnected from the media element to the object can be disposed.
### Steps To Reproduce
1. Include the MediaElement in a MAUI project that is being build for windows
2. Analyse memory trace after page has been navigated away
### Link to public reproduction project repository
//
### Environment
```markdown
- .NET MAUI CommunityToolkit: 12.2.0
- CommunityToolkit MediaElement: 6.1.3
- OS: Windows 11
- .NET MAUI: 9.0
```
### Anything else?
Contributor guide
Research direction
Start by reproducing the Windows MediaElement scenario in a .NET MAUI project, then inspect a memory trace after navigating away from the page. Trace the MediaElement's event handlers and disposal path. Done means the handlers are disconnected and the media element can be collected after navigation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- desktop
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100