Memory usage grows when switching to new Media in MediaPlayer
Summary
I create a VideoView element in Xamarin.Forms, then i initialize the MediaPlayer with a Media object as a parameter, then when MediaPlayer is already assigned i simply switch the Media object by assigning the Media property of the MediaPlayer. I store the result of the Media getter as a private property of the MainPage class and dispose of it when switching to next media, but still the memory usage climbs each time a new media i assigned and after about 50 videos being played has grown to about a few gigabytes.
Minimal project and steps to reproduce
Github repo https://github.com/siggi90/video_test
(I've set the position of each media at near the end of the video to save time while testing but the result is the same if the playback starts at 0.0f.
- Add video files to the playlist (List) private variable to populate the playlist with your own videos.
- build and run for macOS (i've tested on both Mojave and Big Sur with same results)
- open activity monitor and watch memory usage progressively increase over time.
- when playback has completed i noticed memory returns to normal -->
What is the current bug behavior?
Memory usage grows with each successive media being played
What is the expected correct behavior?
I expect each Media's memory to be disposed of when assigning new media and calling Media.Dispose()
Does it work on other plaforms? Does it work with the official VLC apps?
i can provide screenshots of my activity monitor if requested
Relevant logs and/or screenshots
Environment
- OS: macOS
- Version 10.14
- Device: iMac
- LibVLC 3.1.3.1
- LibVLCSharp 3.4.9
Possible fixes
The media seems to not dispose of properly, possibly dispose is not working correctly.