By using time we can easily get the information about how long a program run. I was wondering if there is any equivalent command I can use for memory usages? Like how much memory is allocated for this process, and how much is freed after it finishes? I am aware that I can use Valgrind but it is a bit too heavy-weight for me.

> /usr/bin/time -v sleep 1
Command being timed: "sleep 1"
User time (seconds): 0.00
System time (seconds): 0.00
Percent of CPU this job got: 0%
Elapsed (wall clock) time (h:mm:ss or m:ss): 0:01.01
Average shared text size (kbytes): 0
Average unshared data size (kbytes): 0
Average stack size (kbytes): 0
Average total size (kbytes): 0
Maximum resident set size (kbytes): 1820
Average resident set size (kbytes): 0
Major (requiring I/O) page faults: 1
Minor (reclaiming a frame) page faults: 91
Voluntary context switches: 2
Involuntary context switches: 2
Swaps: 0
File system inputs: 16
File system outputs: 0
Socket messages sent: 0
Socket messages received: 0
Signals delivered: 0
Page size (bytes): 4096
Exit status: 0
  • 2
    Note that this output is from GNU coreutils time. It can also be called with command time instead of the full path. – jordanm Dec 23 '14 at 19:59
  • It is GNU, but it is not coreutils, see directory.fsf.org/wiki/Time – mr.spuratic Apr 2 '15 at 15:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.