Memory leaks in clBuildProgram

Memory leaks in clBuildProgram


Memory usage of attached program continue to increase.
It doesn't happen if a line that contains clBuildProgram call is removed.

I'm using Ubuntu 12.04.1, Intel SDK for OpenCL Applications 2013 (3.0.67279) and g++ 4.6.3.

Downloadtext/x-c++src intel-cl-leak.cpp1.02 KB
6 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

Is there a reason why you are creating and releasing the program objects so many times? Though you are releasing the program everytime there may be some internal state/objects that the runtime maintains that doesnt get released right away. Maybe that's causing the "leak". I'll investigate more but would like to hear why you are doing what you are doing.



I am submitting a bug. Even though what you are doing is not a best practice, nevertheless, you are releasing the program object and this shouldn't result in any memory leaks. Thanks for attaching the test case.


I know that building kernel many times is not a best practice. I found this problem when I was testing my application. This test needs building CL kernel with various parameter combinations.
I hope this bug to be fixed.


We're also having problems with the Intel OpenCL memory leak in clBuildProgram.

We're using version Intel OpenCL CPU Runtime version on Windows 7 and finding that every cycle of clCreateProgram->clBuildProgram->clReleaseProgram leaks significant memory (exactly in the same way that the intel-cl-leak.cpp file attached at the start of this thread demonstrates). This does not occur when the call to clBuildProgram is removed.

Has anyone found a solution to this or is a fix likely to be released?

This is highly problematic to us as we generate our OpenCL program source on the fly before each kernel execution and this can happen to the order of 1,000s of times within a single process space, which means we hit 'out of memory' errors as a result of this bug.



Hi Andy,

I don't have a date yet on the release with the fix. But will keep you posted. I will also escalate the issue.



Leave a Comment

Please sign in to add a comment. Not a member? Join today