First, your dtrace script will give you an upper bound on the maximum memory utilization since you don't track frees as well as mallocs. You might not care about this. If you do care, since free doesn't take in or return the size of the freed range, you might be better off tracing the brk() syscall return value, which also accounts for the size of all metadata that malloc stores on the heap. The a
![How to use dtrace to determine the maximum memory usage of a process](https://cdn-ak-scissors.b.st-hatena.com/image/square/98d6f053a97a87156775f60757c60865d0f2c47d/height=288;version=1;width=512/https%3A%2F%2Fcdn.sstatic.net%2FSites%2Fstackoverflow%2FImg%2Fapple-touch-icon%402.png%3Fv%3D73d79a89bded)