Saturday, February 12, 2011

equivalent of time for memory checking

we can use time in a unix environment to see how long something took...

shell> time some_random_command
real    0m0.709s
user    0m0.008s
sys     0m0.012s

is there an equivalent for recording memory usage of the process(es)?

in particular i'm interested in peak allocation.

  • Can you not use ps? e.g. ps v <pid> will return memory information.

    matpalm : i was using ps but for short lived processes i was having trouble capturing the info
  • Check the man page for time. You can specify a format string where it is possible to output memory information. For example:

    >time -f"mem: %M" some_random_command
    mem: NNNN

    will output maximum resident set size of the process during its lifetime, in Kilobytes.

    From Mathias

0 comments:

Post a Comment