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 220.127.116.11463 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.