unosquare / ffmediaelement

FFME: The Advanced WPF MediaElement (based on FFmpeg)
https://unosquare.github.io/ffmediaelement/
Other
1.17k stars 240 forks source link

Unmanaged references were left alive / Dispose #449

Closed kealist closed 4 years ago

kealist commented 4 years ago

I finally upgraded to latest package (4.1.310) on nuget. I'm still trying to deal with dispose changes from before (#371). I am loading video files locally. This happens after closing the video files

I removed all IDisposable implementations and took out the calls to Dispose. I get the following error.

2019-10-01 08:48:41,012 INFO VideoControl.xaml.cs: 335 - Ch5 (Channel 5) changed state from Pause to Close at 00:00:00
Exception thrown: 'System.OperationCanceledException' in mscorlib.dll
2019-10-01 08:48:41,020 ERROR VideoControl.xaml.cs: 246 - Ch5 (Channel 5): Unmanaged references were left alive. This is an indication that there is a memory leak.
    CodecContext - MediaComponent.cs; Line: 79, Member: .ctor - Instances: 1
    Packet - MediaPacket.cs; Line: 83, Member: CreateReadPacket - Instances: 25
    SwsContext - VideoComponent.cs; Line: 233, Member: MaterializeFrame - Instances: 1

I reverted the removal of IDisposable and added it back in. In the constructor for my wrapper, I set the unloaded behavior to manual:

Player.UnloadedBehavior = MediaPlaybackState.Manual;

I get the same unmanaged references message (with same counts) when I dispose as well. Any thoughts about where this could be occurring?

Issue Categories

Version Information

kealist commented 4 years ago

It appears that this only happens when there are multiple videos open at once.

mariodivece commented 4 years ago

Correct. This is by design. Please see: https://github.com/unosquare/ffmediaelement/issues/424#issuecomment-520191938