I'd like to measure the memory allocated by a block of C/C++ code that I did not write, while the program containing that block us running under Unix. Based on my research so far, I'm planning to use a debugger to break the execution before and after the code block, monitor the /proc/pid/status file at the breakpoints (where pid = process ID of the program containing the code block), and take the difference in one of the metrics reported in /proc/pid/status. Is this an accurate way to do this? I'm also not sure which metric from /proc/pid/status I should be using. Should I use VmRSS or VmSize?