Reporting Peak Memory Used on Program Exit (Linux)
Python:
os.system(‘cat /proc/%d/status | grep Vm’ % os.getpid())
Perl:
system “cat /proc/$$/status”
VmPeak is the peak virtual memory size, and VmHWM (high water mark) is
the peak physical memory (RSS). This beats polling using top - you can
report once at the very end.