1 | initial version |
Yes, you have to free memory using cvReleaseMemStorage().
But as you are learning OpenCV, I strongly recommend using the C++ API. It is easier to understand, easier to use and much easier to avoid memory leaks with it, because you don't have to release memory yourself. The C++ API used to be a wrapper around C core functions and was slower. But there are more and more functions using a C++ core with a C wrapper function. So unless you don't really need high performance for special functions still having a C core, there is almost no reason using the C API.
The corresponding function to the one used in your code above would be findContours()