-
Notifications
You must be signed in to change notification settings - Fork 548
Closed
Description
I think I've discovered a memory leak in the OpenCL backend which occurs during a call to the array::device()
method.
Specifically, in arrayfire/src/backend/opencl/api.cpp
at line 7
namespace af {
template<>
AFAPI cl_mem *array::device() const {
cl_mem *mem_ptr = new cl_mem;
af_err err = af_get_device_ptr((void **)mem_ptr, get());
if (err != AF_SUCCESS)
throw af::exception("Failed to get cl_mem from array object");
return mem_ptr;
}
} // namespace af
The allocation of a new cl_mem
instance on the heap is not released, and the documentation does not indicate to the user that they need to call delete
on the resulting pointer to release the resource. Subsequent calls to array::unlock()
obviously don't release the resource either.
Apologies if I've misunderstood this (perhaps it is a reference counted resource?), but I would appreciate some clarification.
Many thanks.