i have a problem with this code:
//m_buffer is defined elsewhere cl::Buffer result_zb = cl::Buffer(context, CL_MEM_WRITE_ONLY, res_zb->Id(), &ciErrNum); cl::Kernel kernel = OCLUtils::GetInstance()->getCutKernel(); kernel.setArg(0, m_buffer); kernel.setArg(1, result_zb); cl::vector<cl::Memory> buffers; buffers.push_back(m_buffer); buffers.push_back(result_zb); queue.enqueueAcquireGLObjects(&buffers, NULL, NULL); //workgroup sizes are defined elsewhere cl_int ciErrNum = clEnqueueNDRangeKernel(m_queue(), kernel(), 1, NULL, global_workgroup_size, local_workgroup_size, 0, NULL, NULL); queue.enqueueReleaseGLObjects(&buffers, NULL, NULL); clFlush(queue());
when i execute this code for benchmark purposes, i need to execute it for many times sequentially to get significant running times.
the problem is that, after a few repetitions that works correctly, i get a CL_OUT_OF_HOST_MEMORY error
while executing cl::Buffer result_zb = cl::Buffer(context, CL_MEM_WRITE_ONLY, res_zb->Id(), &ciErrNum);
i think this is because memory coming from result_zb is not freed coorectly, so i have a memory leak and my card’s RAM
how can i correctly free the memory? any hints?