我使用的是EE4,每次调用_deviceSource.PreviewWindow = new PreviewWindow(new HandleRef(picBox, picBox.Handle));时,内存使用量都会增加大约60MB。问题是,当我关闭表单并释放_job和_devicesource上的所有资源时,系统不会释放memory...even,如果我调用CG.collect();,系统仍然使用这60MB来执行某些操作。如果我尝试多次调用该窗体,问题会更加严重。在某些时候,我得到了Out of memory (内存不足)错误,因为内存利用率不断增加。有什么建议吗?我检查了SDK示例,在所有情况下问题都仍然存在。所以我的问题是:这是一个bug吗?
发布于 2013-07-09 03:08:49
我的错误...!我没有正确地处理所有的资源:
_deviceSource.PreviewWindow = null;
_job.RemoveDeviceSource(_deviceSource);
_deviceSource.Dispose();释放视频上使用的所有内存资源。
发布于 2013-12-22 20:41:52
我今天遇到了同样的问题。我发现,特别是在调用job.RemoveDeviceSource(source)之前必须先调用source.PreviewWindow.Dispose()
// 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;https://stackoverflow.com/questions/17410980
复制相似问题