clCreateBuffer / clReleaseMemObject Leaks

Discussion created by AndyS on Jun 2, 2010
Latest reply on Jun 3, 2010 by bpurnomo


I'm using a 5770 with ATI Stream 2.1 on Win7 64bit, in a 64bit process. I have long-lived contexts, programs, kernels and make cl_mem buffers and tear them down frequently.

The library does not appear to properly refcount down / release the cl_mem objects.. for example (assume all setup is done):


cl_mem inputImageBuffer;

cl_mem tempImageBuffer;

cl_mem outputImageBuffer;

inputImageBuffer = clCreateBuffer(context,CL_MEM_READ_ONLY,width * height * 4,0,&status);

outputImageBuffer = clCreateBuffer(context,CL_MEM_READ_WRITE,width * height * 4,0,&status);

tempImageBuffer = clCreateBuffer(context,CL_MEM_READ_WRITE,width * height * 4,0,&status);

/* Execute some kernels, etc. etc. */


status = clReleaseMemObject(inputImageBuffer);

status = clReleaseMemObject(tempImageBuffer);

status = clReleaseMemObject(outputImageBuffer);


If you repeat this code N times, it will eventually fail to allocate the buffers at the top. N varies with width*height size, so it looks like a leak. I *am* however executing this code from many separate threads, abeit inside a critical section.

So, unless I've done something stupid (wouldn't be the first time ), either a.) A bug is preventing buffer release or b.) Using openCL from many threads, even though properly critical sectioned, is broken.

Thanks is advance for any advice.