Simple OpenCL program fails eventually due to memory leak

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Simple OpenCL program fails eventually due to memory leak

1,853 Views
andyp
Contributor II

I am using imx6 quad, running Windows Embedded Compact 7 (aka WEC7, Windows CE 7, CE7). The BSP came from Adeneo.

I have found what I believe is a memory leak in the OpenCL software stack. A very simple Vector_Add program runs in a loop ~8000 times and fails with CL error -6.

This file is attached. The .cl file is also attached.

If anyone is an expert in OpenCL and can spot a fault with the Vector_Add program, let me know.

Otherwise, if the problem looks to be in the OpenCL software stack, what is the support model?
How do I get this fixed?

 

andyp

Original Attachment has been moved to: vector_add_kernel.cl.txt.zip

Original Attachment has been moved to: Vector_Add1.cpp.txt.zip

Tags (1)
0 Kudos
Reply
4 Replies

1,324 Views
andyp
Contributor II

More investigation and characterization of the OpenCL memory leak bug reveals that if clCreateContext() is called once, and clReleaseContext() is never called, then the program runs correctly without a memory leak.

My conclusion is that the problem is with clReleaseContext().

0 Kudos
Reply

1,324 Views
CarlosCasillas
NXP Employee
NXP Employee

Deactivated user, could you please comment?

0 Kudos
Reply

1,324 Views
andyp
Contributor II

I added some more checking to my simple OpenCL program.

The checking looked at the reference count for all the OpenCL data structures created with the clCreate* API's. This includes the context, kernel, program, memory buffers, etc.

I found a surprising reference count = 2 for both the kernel object and the program object.

Could there be an implicit increment of the ref count for these 2 objects?

I modified the program to do 2 clReleaseProgram(...) calls and do 2 clReleaseKernel(...) calls each time through the loop.

Now I am retesting.

0 Kudos
Reply

1,324 Views
andyp
Contributor II

Program still eventually fails. Still feels like something wrong with the OpenCL software stack.

I will try to add an attachment for the modified OpenCL program.

0 Kudos
Reply