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?
Microsoft ENcoder SDK memory leak
223 views Asked by Timbolo At
2
There are 2 answers
0
On
I ran into the same issue today. I found that specifically you have to call source.PreviewWindow.Dispose()
before calling job.RemoveDeviceSource(source)
:
// The order in which we remove, dispose, and set null is very important.
// Anything less creates a huge memory leak.
// 1st Stop Encoding
job.StopEncoding();
// 2nd, Must Dispose the Preview Window
// Before Calling Job.RemoveDeviceSource << Absolutely
source.PreviewWindow.Dispose();
source.PreviewWindow = null;
// 3rd, Remove the Source
job.RemoveDeviceSource(source);
// 4th, Dispose the Source
source.Dispose();
source = null;
// 5th, Dispose the Job
job.Dispose();
job = null;
My mistake...! I was not Disposing correctly all the resources:
releases all the memory resources used on the video.