- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
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);
or
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.
jerry
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Jerry,
The latter code is correct: you are responsible for releasing events, otherwise you will leak events as you have observed.

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page