From 2eb8d779e8bc657a8767c4cad7ab72f20f65955f Mon Sep 17 00:00:00 2001 From: Richard Berger Date: Wed, 18 Jul 2018 18:45:40 -0400 Subject: [PATCH] Fixes a memory leak when using OpenCL The GPU package uses OpenCL events for measuring time. These have to be released to free up memory. I removed the clReleaseEvent() calls in the clear() method because in some cases they don't exist yet and I couldn't find a way to check for a valid event (clRetainEvent didn't work). This at least fixes the massive leak during simulations. See issue #1006 --- lib/gpu/geryon/ocl_timer.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/gpu/geryon/ocl_timer.h b/lib/gpu/geryon/ocl_timer.h index 66b79dcab1..1f56aeb364 100644 --- a/lib/gpu/geryon/ocl_timer.h +++ b/lib/gpu/geryon/ocl_timer.h @@ -49,8 +49,6 @@ class UCL_Timer { inline void clear() { if (_initialized) { CL_DESTRUCT_CALL(clReleaseCommandQueue(_cq)); - clReleaseEvent(start_event); - clReleaseEvent(stop_event); _initialized=false; _total_time=0.0; } @@ -107,6 +105,8 @@ class UCL_Timer { CL_SAFE_CALL(clGetEventProfilingInfo(start_event, CL_PROFILING_COMMAND_END, sizeof(cl_ulong), &tstart, NULL)); + clReleaseEvent(start_event); + clReleaseEvent(stop_event); return (tend-tstart)*t_factor; }