title: Is there a way to print the amount of heap memory an object has allocated?
body: <p>In a running program, how can I track/print the amount of heap memory an object has allocated?  </p>
  
  <p>For example:  </p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;vector&gt;
  
  int main(){
  
    std::vector&lt;int&gt; v;
  
    std::cout &lt;&lt; heap_sizeof(v) &lt;&lt; '\n';
  
    for (int i = 0; i &lt; 1000; ++i){
      v.push_back(0);
    }
  
    std::cout &lt;&lt; heap_sizeof(v) &lt;&lt; '\n';
  }
  </code></pre>
  
  <p>Is there an implementation that could substitute <code>heap_sizeof()</code>?</p>