How to free memory allocated by UMat?

asked 2016-03-01 09:45:28 -0500

strann gravatar image

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

edit retag flag offensive close merge delete

Comments