title: How can I know how much memory an STL object takes?
body: <p>I need to gather statistics about memory usage in my program.</p>
  
  <p>My code is mostly written using STL.</p>
  
  <p>Is there any way of learning how much memory is being consumed by an STL object?</p>
  
  <p>For example,</p>
  
  <pre><code>string s1 = "hello";
  string s2 = "hellohellohellohellohellohellohellohellohellohellohellohellohello";
  </code></pre>
  
  <p>How much memory is consumed by <code>s1</code> and <code>s2</code>? 
  Obviously, <code>sizeof(string)+s1.length()</code> is not quite accurate.</p>