umat: fix memory leaks

This commit is contained in:
Alexander Alekhin
2013-12-16 16:46:36 +04:00
parent 11071dd241
commit 9cb31e86ae
4 changed files with 16 additions and 6 deletions

View File

@@ -1469,6 +1469,7 @@ struct Device::Impl
Impl(void* d)
{
handle = (cl_device_id)d;
refcount = 1;
}
template<typename _TpCL, typename _TpOut>
@@ -2693,8 +2694,6 @@ public:
UMatData* defaultAllocate(int dims, const int* sizes, int type, void* data, size_t* step, int flags) const
{
UMatData* u = matStdAllocator->allocate(dims, sizes, type, data, step, flags);
u->urefcount = 1;
u->refcount = 0;
return u;
}
@@ -2736,7 +2735,6 @@ public:
u->data = 0;
u->size = total;
u->handle = handle;
u->urefcount = 1;
u->flags = flags0;
return u;
@@ -2775,7 +2773,6 @@ public:
}
if(accessFlags & ACCESS_WRITE)
u->markHostCopyObsolete(true);
CV_XADD(&u->urefcount, 1);
return true;
}
@@ -2814,6 +2811,9 @@ public:
if(!u)
return;
CV_Assert(u->urefcount >= 0);
CV_Assert(u->refcount >= 0);
// TODO: !!! when we add Shared Virtual Memory Support,
// this function (as well as the others) should be corrected
CV_Assert(u->handle != 0 && u->urefcount == 0);