0

LibVLCSharp is now available for WinUI, and its documentation can be found here.
This is great news, and thank you for sharing it.

I am experiencing an issue with memory usage. Whenever I start and stop the player, not all of the memory is released, and as a result, the memory usage keeps growing..

I tried disposing of the player and the library, but this is not working.

private void MovieWindow_Closed(object sender, WindowEventArgs args)
{
    mp.Stopped += (s, e) =>
    {
        grid.Children.Remove(VideoView);
    };
    mp.Stop();

    var toDispose = mp;
    var toDispose2 = libvlc;
    Task.Run(() =>
    {
        toDispose?.Dispose();
        toDispose2?.Dispose();
    });
}

I have a simple sample available here. Any suggestions on the best approach?

Franck E
  • 629
  • 8
  • 26
  • 1
    In general, you shouldn't dispose in a task, some objects require all calls to happen on the (here UI) thread that created them. However, that doesn't change anything here. I've tested in release, added a call to `GC.Collect(GC.MaxGeneration, GCCollectionMode.Aggressive, true, true);` after each stop and I still miss ~5Mb at each run. Maybe that's expected for some reason, you should ask the guys who develop that nuget, seems to be @mfkl – Simon Mourier May 21 '23 at 08:18
  • Thanks for confirming the issue Simon. – Franck E May 21 '23 at 10:53

1 Answers1

1

I think you ran into the issue that mfkl saw during development : https://github.com/videolan/libvlcsharp/pull/301

If that's the same leak, it was fixed in libvlc : https://code.videolan.org/videolan/vlc/-/merge_requests/3441

However, the fix has not been released yet, it will be in the next libvlc nuget package.

cube45
  • 3,429
  • 2
  • 24
  • 35