Search code examples
sdkexpression-encoder-sdkexpression-encoder-4

Microsoft ENcoder SDK memory leak


I am using EE4 and every time I call _deviceSource.PreviewWindow = new PreviewWindow(new HandleRef(picBox, picBox.Handle)); the memory use increases by around 60 MB. The problem is that when I close the form and dispose all the resources on _job and _devicesource the system does not release the memory...even if I call CG.collect(); the system still uses those 60MB doing something. The problem is even worse if I try to call the form several times. At some point I get the Out of memory error because the memory utilization increases continuously. Any suggestion? I check on the SDK samples and in all cases the problem persist. So my question is: is this a bug?


Solution

  • My mistake...! I was not Disposing correctly all the resources:

    _deviceSource.PreviewWindow = null;
    _job.RemoveDeviceSource(_deviceSource);
    _deviceSource.Dispose();
    

    releases all the memory resources used on the video.