Why is the ImageViewerWpfControl not disposed?

We have a WPF application where the user can open multiple windows with video. These contain the ImageViewerWpfControl. Eventually the app crashes with an out of memory exception. It looks like not all controls are disposed when a windows is closed.

I’ve modified the PlaybackWpfUser example (see attached file) to mimic this behavior.

I suspect the SDKDigitalZoomInfoUserControl (WinformsAdapter) or some other eventhandler is not properly disposed. Or is there some other way the make sure everything is removed from memory?

I have downloaded the project and will take a look..

Thanks! By the way I used the latest MIPSDK for this project. But to make it work properly I had to copy “VideoOS.Common.Definition.dll” and “VideoOS.Common.login.dll” from a Smart Client bin folder. I also added a NuGet package (Blend.Interctivity.WPF.v4.0) for the missing “System.Windows.Interactivity.dll”.

Hi David

Thanks a lot for providing the sample that made it fairly easy to reproduce the issue. It took a little digging to find the reason for the leak as it turned out to be caused by a number of issues. However, we now believe we have fixed it, and have uploaded a hotfixed version of MIPSDK 2018 R3 here:

http://download.milestonesys.com/MIPSDK/HOTFIX/TFS196994/MIPSDK_Installer_2018R3.msi

It contains some changes to the VideoOS.Platform.SDK.UI.dll, which will of course also be part of the 2019 R1 release.

In addition to the fixes in the platform dll a change is also needed in the sample, so that the Window_Closed method should now look like this:

   private void Window\_Closed(object sender, EventArgs e)

   {

       \_imageViewerControl.Disconnect();

       \_imageViewerControl.Close();

       \_imageViewerControl.Dispose();

       if (\_playbackFQID != null)

       {

           \_playbackUserControl.Close();

           ClientControl.Instance.ReleasePlaybackController(\_playbackFQID);

           \_playbackFQID = null;

       }

       //VideoOS.Platform.SDK.Environment.RemoveAllServers();

       \_mc?.Dispose();

       \_dateTimePicker?.Dispose();

       \_winFormsHost.Dispose();

   }

(you also need to assign a name to the WinFormsHost in the XAML).

Regarding the missing dlls this is a bit of a mystery to us as they should not be required, but will look further into that.

Hi Peter,

Thanks! This seems to work.