Using opencl in loop

Hi, I am not able to solve an issue regarding opencl.

My program flow is something like this:

loop()
{
initGPU();
makeSomethingOnGPU()
destroyGPU();
}

I MUST put initialization and destroy steps inside the loop. After a number of correct iterations , it crashes giving CL_OUT_OF_HOST_MEMORY error and I am not able to understand why.
I believe I destroy all resources. Following is the code

initGPU: http://pastebin.com/g81aeuNG

makeSomethingOnGPU: http://pastebin.com/YT3Am25g

destroyGPU: http://pastebin.com/uqju4wp9

You are leaking host memory in initGPU. If you run Task Manager you’ll see that your memory usage just keeps growing. Everything that has a “new” must have a matching “delete”.

Are you referring to various arrays? should it be done by java?

Oh, that’s Java? Sorry, didn’t catch that. Well, I can’t help you much then except to still say that something is leaking host memory. Do you see Task Manager memory usage grow as your application runs?

I might ask you you feel you must destroy and subsequently rebuilt the OpenCL platform, device, context, program, and kernels for each iteration through your loop. Seems wasteful.

Sorry, I forgot to mention it were Java. I ran Task Manager (“top” in linux systems) and I noticed that memory grows up until maximum (I can also hear the fan). I removed all variables and the problem per

I might ask you you feel you must destroy and subsequently rebuilt the OpenCL platform, device, context, program, and kernels for each iteration through your loop. Seems wasteful.

I am working with Hadoop framework and I need of initialize various nodes to work with its gpu. I do not think it is possibile to init just once.

Using a profiler I found that Buffers (byte[]) are not deallocated after each loop so they lie on GC (Garbage Collector). Is there a way to deallocate in opencl?

The problem moved to CL_OUT_OF_RESOURCES now.

Does anyone have same problem?