Opencv Resize memory leak
I am using the cv::resize function from opencv (2.4.3). I am getting a memory leak. This it the code:
Mat src(height_,width_,CV_8UC3,(void *)&bits_[0]);
cv::resize(src, src,cv::Size(width,height));
BMPImage result (src);
src.release();
src = NULL;
I have a memory leak in cv::resize... This code is used a lot of times (It resizes hundred images in an execution) and the memory doesn't stop to increase.... I was checking the opencv documentation but It explains that cv::resize handles its memory...
In my log, it get the error from the deallocation:
0x22081 call 0x6118 <?deallocate@?$AutoBuffer@E$0BAAI@@cv@@QAEXXZ>
Update
I fixed the memory leak problem.... with this code
Mat src(height_,width_,CV_8UC3,(void *)&bits_[0]);
Mat dst;
cv::resize(src, dst,cv::Size(width,height),0,0,INTER_CUBIC);
BMPImage result (dst);
src.release();
dst.release();
src = NULL;
dst = NULL;
This code doesn't fix the deallocation problem with it is related to:
src.release();
src = NULL;
If I have a moment, I will investigate it.
again : src.release() does nothing, and dst.release() will be called automatically on end of scope.
but where do your bits_ come from originally ? if they were dynamically allocated, you'll have to delete[] them manually after use.
berak, you are right, but the problem was in the bits_ array.... Also, I removed src.release() and dst.release(). Thanks!