Memory Leak in Zivid Application

Problem

Your program stops due to memory leak.

Error

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]

You can check this by opening Task ManagerPerformance and see how much of memory is used while running your program.

Memory leak when making many Zivid applications sequentially within the same process

Possible cause

For Zivid SDK 2.6 and older, a memory leak in Zivid::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);
}

Solutions

Upgrade Zivid SDK to 2.7 or newer. Alternatively, modify your code not to make multiple Zivid applications sequentially within the same process. Often, this boils down to moving Zivid application outside the loop.

Zivid::Application zivid;

while(true)
{
    const auto settings = Zivid::Settings{ Zivid::Settings::Acquisitions{ Zivid::Settings::Acquisition{} } };
    zivid.connectCamera().capture(settings);
}