Shell – Equivalent command for “time“ for memory usage

memorymonitoringprocessshell

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.

Best Answer

> /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
Related Question