today i encountered a strange memory increase when i run my OpenCL application. In my case the issue seems to be the OpenCL cl_events.
I use clEnqueueNDRangeKernel(..., &my_event); which returns an OpenCL event. Later in my application i use clWaitForEvents();
Who is responsible for releasing "my_event"? When i only use the commands above i get a memory increase every cycle i call clEnqueueNDRangeKernel(...). When i call clReleaseEvent(my_event); after calling clWaitForEvents(); than the memory leak is gone.
I cannot found something in the OpenCL specification. Thus which code is correct?
clEnqueueNDRangeKernel(..., &my_event); ... clWaitForEvents(1, &my_event);
clEnqueueNDRangeKernel(..., &my_event); ... clWaitForEvents(1, &my_event); clReleaseEvent(my_event);
I also checked the reference count of my_event after a call to clWaitForEvents(...) with clGetEventInfo(my_event, CL_EVENT_REFERENCE_COUNT,...). The reference count is still 1 and not 0. So it seems that without clReleaseEvent() the reference count nether gets 0 and thus the resources for the event are not released.