Tracking memory usage
… or why using Linux can be a pain, when you come from the BSD-world.
On BSD (and MacOSX and probable other UNIXes), if you want to track a program’s memory usage, you can simply issue the following in a CSHELL
set time= ( 0 "%D KB avg / %K KB total / %M KB max" )
or just use /usr/bin/time’s l-parameter.
On GNU/Linux on the other hand, rusage as defined by POSIX is not completely implemented, so you cannot do this. A workaround is preloading /lib/libmemusage.so which plugs into your program’s memory allocation, keeps track of stuff and prints funky statistics in the end.