Zivid Application的内存泄漏问题
问题
当您的程序因内存泄漏而停止。
错误
Error: An OpenCL error occurred: Failed to enqueue kernel
Your OpenCL device (GPU or CPU) does not have enough resources to execute the current task.
Verify that there are no other programs running that consume memory from this OpenCL device.
Also check that your OpenCL device meets the minimum requirements, and if necessary upgrade it to a more capable model.
[CL_MEM_OBJECT_ALLOCATION_FAILURE]
您可以通过打开 Task Manager → Performance 来检查这个问题,看看有多少内存在运行程序时被使用。
可能的原因
For Zivid SDK 2.6 and older, a memory leak in Application destructor could cause out-of-memory errors when making many applications sequentially within the same process.
The example code below causes a memory leak.
while(true)
{
Zivid::Application zivid;
const auto settings = Zivid::Settings{ Zivid::Settings::Acquisitions{ Zivid::Settings::Acquisition{} } };
zivid.connectCamera().capture(settings);
}
解决方案
将Zivid SDK升级到2.7或更高版本。 或者修改您的代码,不要在同一进程中按顺序创建多个Zivid应用程序。 通常重点是如何将Zivid应用程序移到循环之外。
Zivid::Application zivid;
while(true)
{
const auto settings = Zivid::Settings{ Zivid::Settings::Acquisitions{ Zivid::Settings::Acquisition{} } };
zivid.connectCamera().capture(settings);
}