How to avoid memory leaks in OpenCV
Today I fixed a memory bug in one of my programs. Albeit I always release memory cvReleaseImage after allocating it with cvCreateImage, memory consumption was enormous. Commenting out some of the source code quickly showed the responsible code fragments. Using cvCreateImage and afterwards cvCloneImage made it impossible to release the initially allocated memory. Therefore after some iterations (depending on your main memory) this program will crash. To fix this issue simply replace the cvCloneImage with cvCopy.
Bad code:
Good code:
Last Updated (Thursday, 08 July 2010 21:54)


