title: How to use dtrace to determine the maximum memory usage of a process
body: <p>The following dtrace script will give the sum of all allocations a process has performed:</p>
  
  <pre><code>pid$target::malloc:entry { @ = sum(arg0); }
  </code></pre>
  
  <p>Now, I'm rather interested in the maximum total allocated memory usage during the life-span of the process (about 50 ms). How can I generate either what would be a graph over time of total allocated memory usage (sum of all mallocs minus sum of all frees), or just its maximum value. I've tried keeping track of all allocated memory blocks manually, but the dtrace associative array size limit is exceeded.</p>