Linux – Peak memory usage of a linux/unix process

command linelinuxmemory-management

Is there a tool that will run a command-line and report the peak RAM usage total?

I'm imagining something analogous to /usr/bin/time

Best Answer

[Edit: Works on Ubuntu 14.04: /usr/bin/time -v command Make sure to use the full path.]

Looks like /usr/bin/time does give you that info, if you pass -v (this is on Ubuntu 8.10). See, e.g., Maximum resident set size below:

$ /usr/bin/time -v ls /
....
        Command being timed: "ls /"
        User time (seconds): 0.00
        System time (seconds): 0.01
        Percent of CPU this job got: 250%
        Elapsed (wall clock) time (h:mm:ss or m:ss): 0:00.00
        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): 0
        Average resident set size (kbytes): 0
        Major (requiring I/O) page faults: 0
        Minor (reclaiming a frame) page faults: 315
        Voluntary context switches: 2
        Involuntary context switches: 0
        Swaps: 0
        File system inputs: 0
        File system outputs: 0
        Socket messages sent: 0
        Socket messages received: 0
        Signals delivered: 0
        Page size (bytes): 4096
        Exit status: 0