title: Free memory of cv::Mat loaded using FileStorage API
body: <p>I'm working on a system that continuously loads and releases OpenCV Matrices using OpenCV FileStorage API. These matrices hold images feature descriptors. In concrete the piece of code that does the job is this one:</p>
  
  <pre><code>descriptors.create(rows, cols, type);
  
  ...
  
  for (cv::FileNodeIterator it = keypointsSequence.begin(); it != keypointsSequence.end(); it++, idx++) {
  
      ...
  
      cv::Mat featureVector;
      (*it)["descriptor"] &gt;&gt; featureVector;
  
      featureVector.copyTo(descriptors.row(idx));
      featureVector.release();
  }
  </code></pre>
  
  <p>As I understand from <a href="http://answers.opencv.org/question/14285/how-to-free-memory-through-cvmat/" rel="nofollow">this post</a> a <code>cv::Mat</code> is released only when it was created using <code>Mat::create</code>. Though I'm using the create method, its content is being copied from the loaded matrix.</p>
  
  <p>I have a couple of questions:</p>
  
  <ol>
  <li>Is <code>featureVector</code> being correctly released and hence its memory deallocated? Or do I have to delete it manually?</li>
  <li>How correct is it defining <code>featureVector</code> inside the loop? And how does it impact the overall performance (specially in memory)?</li>
  </ol>
  
  <p>I would strongly appreciate any insight about this issues.</p>