title: QVector(or std::vector) reserve(or resize) down doesn't free memory
body: <p>Say I have a <code>QVector</code> and I call QVector::reserve for 420000 elements. Right after that I call <code>QVector::reserve</code> again for 42 elements. What I noticed is that after doing this, the process still has memory allocated for those 420000 elements. Why doesn't memory get freed when I shrink the <code>QVector</code> size to 42?</p>
  
  <p>Take the following code:</p>
  
  <pre><code>#include &lt;QCoreApplication&gt;
  #include &lt;QVector&gt;
  #include &lt;QDebug&gt;
  
  typedef QVector&lt;QPointF&gt; PointVec;
  typedef QList&lt;PointVec*&gt; PointVecList;
  
  int main(int argc, char *argv[])
  {
      QCoreApplication a(argc, argv);
  
      qDebug() &lt;&lt; "Processing...";
  
      PointVecList list;
  
      for (int i = 0; i &lt; 4200; i++) {
          PointVec *v = new PointVec();
  
          v-&gt;reserve(420000);
          v-&gt;resize(420000);
  
          v-&gt;reserve(42);
          v-&gt;resize(42);
  
          list.append(v);
      }
  
      qDebug() &lt;&lt; "End of processing...";
  
      return a.exec();
  }
  </code></pre>
  
  <p>This code crashes throwing <code>std::bad_aloc</code> exception(<code>Unhandled exception at 0x7729C41F in QtConsoleApplication1.exe: Microsoft C++ exception: std::bad_alloc at memory location 0x0034F5E8.</code>) on a 32 bit system(as the system doesn't support much RAM for one process).</p>
  
  <p>However if I comment lines <code>v-&gt;reserve(420000);</code> and <code>v-&gt;resize(420000);</code> everything works fine. This is how I noticed that if I call <code>v-&gt;reserve(42);</code> and <code>v-&gt;resize(42);</code>(after reserving/resizing the vector to 420000 elements beforehand) exceeding memory doesn't get freed.</p>
  
  <p>What I also noticed is that <code>std::vector</code> behaves exactly the same.</p>
  
  <p>Is it possible to force <code>Qt</code> to also free the memory? If not, is it possible to free it myself, manually, somehow?</p>