3 Replies Latest reply on Jun 3, 2010 8:45 AM by bpurnomo

    clCreateBuffer / clReleaseMemObject Leaks



      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.


        • clCreateBuffer / clReleaseMemObject Leaks

          I'm having a similar problem on 5870 with ATI Stream 2.1 on Win7 64bit.

          If I do:

          cl_int count; cl_mem a = clCreateBuffer(context, CL_MEM_READ_ONLY, sizeof(cl_float) * globalSize, NULL, &err); clGetMemObjectInfo(a, CL_MEM_REFERENCE_COUNT, sizeof(cl_int), &count, NULL); //count will equal 1 as expected. //But then if i do: clEnqueueWriteBuffer(commandQ, a, CL_TRUE, 0, sizeof(cl_float) * num, (void*) a, 0, NULL, NULL); clGetMemObjectInfo(a, CL_MEM_REFERENCE_COUNT, sizeof(cl_int), &count, NULL); //count now equals 2. Is it supposed to? //The documentation doesn't say anything about clEnqueueWriteBuffere increasing a's reference count.