OpenCV memory management of cv::Mat
<p>I am quite new to OpenCV and having some memory leaks in my application, due to cv::Mat usage. If I use a Mat as follows:</p>

<pre><code>cv::Mat mat = matProducingFunctionFoo();
</code></pre>

<p>How can I free the memory after I am done with mat object. I know (from other posts) if I use create function or constructors with size and type parameters, I can call for the release function of the mat. However here I am not certain about the size or type of the mat, so it is dynamic. How can I free the memory (release is not working in this case)?</p>