2016-07-30 19:48 GMT+02:00 Armin Rigo email@example.com:
Fwiw, there is some per-OS (and even apparently per-Linux-distribution) solution mentioned here: http://stackoverflow.com/questions/774556/peak-memory-usage-of-a-linux-unix-...
For me on Arch Linux, "/usr/bin/time -v CMD" returns a reasonable value in "Maximum resident set size (kbytes)". I guess that on OSes where this works, it gives a zero-overhead, exact answer.
Oh, I guess that it uses the ru_maxrss field of getrsage(RUSAGE_CHILDREN). It's also possible to get the maximum RSS of the current process in pure Python:
It looks like Linux kernel 2.6.32 or newer is required. Hopefully, this kernel version is now quite old (December 3rd 2009).
But I guess that RSS is more coarse than getting the sum of the private memory from /proc/pid/smaps (Linux 2.6.16 or newer). Sadly, it looks like the kernel only provides the maximum for RSS memory (not for private memory).