Meta.Vlc icon indicating copy to clipboard operation
Meta.Vlc copied to clipboard

Potential handle leak when recreating VlcPlayer instances

Open LarsWesselius opened this issue 7 years ago • 1 comments

I'm encountering a potential handle leak when recreating a VlcPlayer instance every second. Here's the code;

        public MainWindow()
        {
            InitializeComponent();

            var disp = Dispatcher;
            Meta.Vlc.Wpf.VlcPlayer vlc = new VlcPlayer(disp);
            vlc.Initialize("libvlc");
            vlc.LoadMedia("1.mp4");
            vlc.Play();

            Task.Run(async () =>
            {
                while (true)
                {
                    await Task.Delay(1000);

                    vlc.Stop();
                    vlc.Dispose();

                    disp.Invoke(() =>
                    {
                        vlc = new VlcPlayer(disp);
                        vlc.Initialize("libvlc");
                        vlc.LoadMedia("1.mp4");
                        vlc.Play();
                    });


                }

            });
        }

It's really lazy, I know.

image

On the arrow is where I started the above code and let it run for a while. The graph shows open handles by process. The above code is all that's done in the project. There's no other code running.

I'm also getting the handle leak in my custom VlcPlayer, using my own render process through SetVideoDecodeCallbacks, etc.

Any ideas?

LarsWesselius avatar Jul 03 '17 07:07 LarsWesselius

Create player is a very heavy operation, I think you should multiplexing players.

devkanro avatar Jul 05 '17 04:07 devkanro