title: Memory usage per-function in C?
body: <p>How can I measure the memory usage of individual C functions?</p>
  
  <p>Especially peak dynamic and/or stack allocation during the function, not just a heap allocation delta from entry to exit.  Memory usage isn't like CPU usage where <code>get_cpu_time</code> at the start/end of a function does tell you something useful for large functions.</p>
  
  <p>Over multiple calls to a function, max and median or mean would be interesting, especially if we can see how it scales with a function arg.</p>
  
  <p>Total cache footprint touched during execution would also be interesting.</p>