Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

How to free memory allocated by UMat?

Hi,

I need to free memory allocated by UMat during code execution, so I don't have an out of memory error. I'm using OpenCV 3.1.0 with CUDA 7.5. Here's what I've tried:

    cv::cuda::DeviceInfo di;
    size_t totalMemory;
    size_t freeMemory;
    di.queryMemory(totalMemory, freeMemory);
    cout << freeMemory/1024/1024 << endl;
    UMat m = UMat::zeros(1000,1000, CV_8SC1);
    di.queryMemory(totalMemory, freeMemory);
    cout << freeMemory/1024/1024 << endl;
    m.release();
    di.queryMemory(totalMemory, freeMemory);
    cout << freeMemory/1024/1024 << endl;
    return 0;

Output: 1527 1497 1498