title: Will STL deque pop_front() automatically recycle memory?
body: <p>I have a program in which I collect some data and store them temporarily in a deque</p>
  
  <pre><code>    typedef vector&lt;float&gt; floatVector;
      ...
      floatVector * currRecord;
      deque&lt;floatVector *&gt; data;
      ...
      ...
  
      for (...)
      {
          ...
          currRecord = new floatVector(10); 
          data.push_back(currRecord);
      }
  </code></pre>
  
  <p>Later, I want to save data to file</p>
  
  <pre><code>    while (data.size() &gt; 0) 
      {
          for (int i=0; i &lt; 10; i++) 
          {
              fprintf(fPtr, "%lf\t", data[0]-&gt;at(i) );
          }
      fprintf(fPtr,"\n");
      data.pop_front();
      }
  </code></pre>
  
  <p>So, my question is, will this program cause a memory leak? I use <code>new</code> operator to allocate memory for each <code>currRecord</code> vector. Will the deque <code>pop_front</code> function automatically recycle memory? Or do I need to put </p>
  
  <pre><code>    delete [] data[0]
  </code></pre>
  
  <p>before </p>
  
  <pre><code>    data.pop_front();
  </code></pre>
  
  <p>? Also, if <code>data</code> is a vector instead of a deque, will everything be the same? Thanks!</p>