title: Nested STL vector using way too much memory
body: <p>I have an STL vector <code>My_Partition_Vector</code> of <code>Partition</code> objects, defined as</p>
  
  <pre><code>struct Partition // the event log data structure
  {
      int key;
      std::vector&lt;std::vector&lt;char&gt; &gt; partitions;
      float modularity;
  };
  </code></pre>
  
  <p>The actual nested structure of <code>Partition.partitions</code> varies from object to object but in the total number of chars stored in Partition.partitions is always 16.</p>
  
  <p>I assumed therefore that the total size of the object should be more or less 24 bytes (16 + 4 + 4).  However for every 100,000 items I add to <code>My_Partition_Vector</code>, memory consumption (found using ps -aux) increases by around 20 MB indicating around 209 bytes for each Partition Object.</p>
  
  <p>This is a nearly 9 Fold increase!?  Where is all this extra memory usage coming from?  Some kind of padding in the STL vector, or the struct?  How can I resolve this (and stop it reaching into swap)?</p>