I was using CodeXL to do some profiling and it kept saying:
Opencl Memory leak detected [Ref =1] Object created by clEnqueueNDRangeKernel
Eventually it was narrowed down to this line:
status = clEnqueueTask( myQueue, myKernel, 0, NULL, NULL) ;
After changing it to:
|status = clEnqueueTask( myQueue, myKernel, 0, NULL, &clEvent ) ;|
clReleaseEvent ( clEvent ) ;
The memory leak went away.
As per the specs, when passing in NULL no event object should be created, but it clearly was in this case.
I tried it on a 6950 and 280x, both using the 13.12 catalyst driver and they both have this issue.
clEnqueueNDRangeKernel( myQueue, myKernel, workDims, global_work_offset,(const size_t *)global_work_size, local_work_size, 0, NULL, NULL) ;
If I use this instead of clEnqueueTask it also runs into the same problem with a memory leak, which can be solved the same way.
It turns out the issue with the reported memory leak in clEnqueueTask is actually a bug in CodeXL. CodeXL is not doing the right thing when tracing the clEnqueueTask API. We will try to get a fix in place for the next version of CodeXL.
Thanks you for reporting this issue.
I ran the taskParallel code from (http://www.fixstars.com/en/opencl/book/OpenCLProgrammingBook/calling-the-kernel/) and there was no memory leak reported in CodeXL (v 1.4) on my HD 6520G machine with catalyst driver 184.108.40.206.
Please can you check with the latest driver and CodeXL and let me know your findings.