How does /usr/bin/time measure memory usage?
I didn't check source of time
. But There are wait3
and wait4
functions for getting rusage
of child process:
pid_t wait3(int *status, int options, struct rusage *rusage);
pid_t wait4(pid_t pid, int *status, int options, struct rusage *rusage);
struct rusage
contains the maximum resident set size value.
Man page getrusage(2) describes the struct rusage
.
I looked at the source (it's very short). It uses getrusage()
.