Problem creating cl_context

Hi everybody. I’m experimenting with OpenCL and I faced the following problem: inside my code I have a function that is performed on the GPU using OpenCL. Every time the function is called I perform the whole OpenCL environment setup with the context and command queue creation, the program build and so on. Right now I don’t care about performance, I know it is very slow. The problem is that after 15 calls to the function I cannot create a new context. The error number is -6, CL_OUT_OF_HOST_MEMORY but I don’t see any problem with the local host memory, I’m not working with big data sets.
At the end of the function I release the context and in theory I would not face any problem. The GPU I’m using is the Nvidia GTX480, and curiously the number of Streaming Multiprocessor is 15 as the number of function I context I can create before the memory error. Can anybody explain me this behavior? Thanks

Tommy

My best bet would be that you are releasing the context but you are forgetting to release some other resource, like the command queue, or some memory object, or a kernel.

That CL_OUT_OF_HOST_MEMORY error is almost certainly trying to say “out of some resource in the host, not necessarily memory”. It could be out of mutexes for all we know.