How to determine size of data (allocated and deallocated) during runtime
<p>I have two questions:</p>

<p>1.) I want to do memory profiling of my code in a function-wise manner. The code can have any STL containers. Is there a way of doing this in linux?</p>

<p>2.) The second one is due to my naivety!! If I have a data-structure</p>

<pre><code>template &lt; class T1 &gt; struct somestruct
{
std::set &lt; T1 &gt; v1;
std::vector &lt; T1 &gt; v2;
std::vector &lt; T1 &gt; v3;
};
</code></pre>

<p>and I know the sizes of v1, v2 and v3 then can I do a straightforward calculation of the size of the structure based on sizeof(T1) or would I have to take care of padding?</p>
