Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

How do I measure the peak memory of an application running on Linux?

I run this app in batch so I cannot use RSS since, it reports the current memory. I need the peak memory that the application has used to be reported at the end.

The VmPeak is not a solution either, since it reports the allocated memory and also does not calculates from the real Ram but also from the Hard Disk.

share|improve this question
What OS are you running the application on? –  Michael Kjörling May 28 '13 at 11:26
I am working on Linux –  des_user May 28 '13 at 11:38
This thread should be of help to you: serverfault.com/questions/387268/… –  Jacob Coleman May 28 '13 at 14:52
add comment

1 Answer

Here are 2 methods for tracking a processes' peak memory usage.


I haven't used this tool but it sounds like what you're looking for. It's called Syrupy.


Syrupy is a Python script that regularly takes snapshots of the memory and CPU load of one or more running processes, so as to dynamically build up a profile of their usage of system resources.


$ syrupy.py myprog

14634 2008-10-10  20:45:25   00:00  0.0   0.0   2996    6680
14634 2008-10-10  20:45:26   00:01  105   0.2   7804   12592
14634 2008-10-10  20:45:27   00:02  103   0.2   8996   13776
14634 2008-10-10  20:45:28   00:03  103   0.2  10468   15348
14634 2008-10-10  20:45:29   00:04  103   0.3  11412   16396
14634 2008-10-10  20:45:30   00:05  104   0.3  12492   17444

/usr/bin/time -v

Yes ironically the GNU time command can give you the peak memory usage of a process. It reports the peak memory like so: Maximum resident set size (kbytes).


$ /usr/bin/time -v ~/projects/prime_numbers/eratosthenes_prime_sieve.pl 10 1000000

    Command being timed: "/home/saml/projects/prime_numbers/eratosthenes_prime_sieve.pl 10 1000000"
    User time (seconds): 1.12
    System time (seconds): 0.05
    Percent of CPU this job got: 54%
    Elapsed (wall clock) time (h:mm:ss or m:ss): 0:02.19
    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): 79304
    Average resident set size (kbytes): 0
    Major (requiring I/O) page faults: 0
    Minor (reclaiming a frame) page faults: 20014
    Voluntary context switches: 83
    Involuntary context switches: 274
    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


share|improve this answer
add comment

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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