-1

I am trying to measure the RAM usage of MyProcess args

GNU time

Following this post

gtime -v ./MyProcess args

[..]
Maximum resident set size (kbytes): 303316992 # (303 GB)
[..]

I clearly don't have 303 GB of RAM on my computer!

zsh - time

Following this post

zsh
TIMEFMT='%J   %U  user %S system %P cpu %*E total'$'\n'\
'avg shared (code):         %X KB'$'\n'\
'avg unshared (data/stack): %D KB'$'\n'\
'total (sum):               %K KB'$'\n'\
'max memory:                %M MB'$'\n'\
'page faults from disk:     %F'$'\n'\
'other page faults:         %R'

time ./MyProcess args

avg shared (code):         0 KB
avg unshared (data/stack): 0 KB
total (sum):               0 KB
max memory:                73204 MB # (73 GB)
page faults from disk:     0
other page faults:         18528

I don't have 73 GB of RAM on my machine either!

tstime

Following this post... I failed to install it!

Activity Monitor

The activity monitor gives me a RAM usage of about 60 MB. This is typically the RAM usage I was expecting.

Of course, MyProcess is deterministic and RAM usage should not vary from one run to another.

Can you help me to figure out what is going wrong (if anything) and how I can measure RAM usage of a process with a time like type of command?


FYI, I use Mac OS X 10.11.3

  • I do not understand the usz-time section the question you mention does not show usz or time and the first post actually gives you the answer. Please check what you have written as the URLs don't say what you quote – Mark Mar 27 '17 at 1:57
  • Also time ./MyProcess arfs does not do what you say it does – Mark Mar 27 '17 at 11:03
4

First OS X is not Linux so don't assume that Linux doxumentation works.

I think you have actually got the correct answer in the output of time - the maximum resident set size is 73MB. (This code snippet implies that non macOS has the size in kilobytes whilst Apple as in the documentation below is in bytes)

Use OSX man pages start at man time - so time -l ./process gives

-l The contents of the rusage structure are printed.

The rusage structure is set by getrusage() which includes fields

struct rusage {
             struct timeval ru_utime; /* user time used */
             struct timeval ru_stime; /* system time used */
             long ru_maxrss;          /* max resident set size */

and

ru_maxrss the maximum resident set size utilized (in bytes).

so time -l ./MyProcess args should give what you want.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .