Possible memory leak in Video Player

The second line from the top shows 6 instances of byte data held by 6 callback instances:

This seems to happen when navigating between main menu screens. The background video is unloaded and loaded again (perhaps not the best way to do things).
Video.PlatformInitialize() gets called when loading video content. This results in a new instance of VideoSampleGrabber being created, with a byte buffer for video frame data. The old instance(s) stay in memory however, creating the leak.

Video.PlatformDispose() seems never to be called when unloading the video content…

Video.Dispose() looks like this:

void Dispose(bool disposing)
        {
            if (!_disposed)
            {
                //PlatformDispose(disposing);
                _disposed = true;
            }
        }

PlatformDispose() has been commented out, why is that? It creates a memory leak in Video.WMS.

Uncommenting it causes the program to crash…

The video player seems to have more issues like this:

At least some of the issues with the video player should be fixed by https://github.com/MonoGame/MonoGame/pull/5084

I already merged those changes.

Then you should open a new issue on GitHub. Bump @KonajuGames

Here is the new issue:

Any updates on this? I tried MONOGAME 3.6 and 3.5 and have the same leak. Every time I play a video, my simple game’s memory grows by over 100 MB. The game starts at 42 MB and grows to over 500 MB after playing the video 4 or 5 times. I’m now shelling VLC to play the video, but that is a horrible way to fix the issue.

There was a fix merged into the develop branch this past week, and I have just now updated my more complete PR for better video playback.

Thanks for the quick response. I’ve downloaded the source and added to my project. Removed original Windows Monogame.Framework and added new reference that was added to my project in prior step. All compiles with no errors and game launches fine. But, when trying to play the video, I get:

An exception of type ‘SharpDX.SharpDXException’ occurred in SharpDX.dll but was not handled in user code

Additional information: HRESULT: [0x80004002], Module: [General], ApiCode: [E_NOINTERFACE/No such interface supported], Message: No such interface supported

Is the error on the same line as mentioned in the comments on that PR?

I’m sorry. I’m a bit of a noob when it comes to GitHub. I was able to install Git Desktop and download the source and get that to compile. But, I’m afraid I’m not sure about PRs and branches and the like.

It is crashing at:

private void OnTopologyReady()
{
if (_session.IsDisposed)
return;

        // Get the volume interface.
        IntPtr volumeObjectPtr;

MediaFactory.GetService(_session, MediaServiceKeys.StreamVolume, AudioStreamVolumeGuid, out volumeObjectPtr);

_volumeController = CppObject.FromPointer(volumeObjectPtr);

        SetChannelVolumes();
    }

That does look like the same issue. Unfortunately I don’t get the same issue here with the video linked in the PR. Are you able to share your video for testing?