How to measure the memory usage of a program? - Suse

This is a discussion on How to measure the memory usage of a program? - Suse ; I asked this same question in alt.os.linux, but got no good answers. I have got very helpful answers in this group in the past, so maybe this time will also be so?-) I want to measure how much memory a ...

+ Reply to Thread
Results 1 to 5 of 5

Thread: How to measure the memory usage of a program?

  1. How to measure the memory usage of a program?

    I asked this same question in alt.os.linux, but got no good answers.
    I have got very helpful answers in this group in the past, so maybe this
    time will also be so?-)

    I want to measure how much memory a program allocates for itself. The
    program only runs for a few seconds (constantly allocating more and more
    memory during its runtime). Thus tools like 'top', 'pmap' or 'ps v' are
    of no use. valgrind prints the summed amount of memory allocated by all
    the mallocs executed by the program, which is larger than the actual
    amount of memory used by the program (because the program also frees
    memory from time to time). Thus it's not useful either.
    '/usr/bin/time -f "%M"' was my most promising find, except that it
    doesn't work (always prints "0").

    Any suggestions?

  2. Re: How to measure the memory usage of a program?

    Juha Nieminen wrote:

    > I asked this same question in alt.os.linux, but got no good answers.
    > I have got very helpful answers in this group in the past, so maybe this
    > time will also be so?-)
    >
    > I want to measure how much memory a program allocates for itself. The
    > program only runs for a few seconds (constantly allocating more and more
    > memory during its runtime). Thus tools like 'top', 'pmap' or 'ps v' are
    > of no use. valgrind prints the summed amount of memory allocated by all
    > the mallocs executed by the program, which is larger than the actual
    > amount of memory used by the program (because the program also frees
    > memory from time to time). Thus it's not useful either.
    > '/usr/bin/time -f "%M"' was my most promising find, except that it
    > doesn't work (always prints "0").
    >
    > Any suggestions?

    If you're using kde try Ksysguard. VmSize is the total amount of virtual
    memory used by the process and VmRss is the total amount of physical memory
    used by the process . I think that will give you what you're looking for
    but maybe someone else will have a better answer.

  3. Re: How to measure the memory usage of a program?

    Michael Soibelman wrote:
    > Juha Nieminen wrote:
    >> The program only runs for a few seconds


    > If you're using kde try Ksysguard. VmSize is the total amount of virtual
    > memory used by the process and VmRss is the total amount of physical memory
    > used by the process . I think that will give you what you're looking for
    > but maybe someone else will have a better answer.


    Please read my description of the situation again? I quoted the most
    relevant part of my original post above.

  4. Re: How to measure the memory usage of a program?

    Juha Nieminen wrote:

    > I asked this same question in alt.os.linux, but got no good answers.
    > I have got very helpful answers in this group in the past, so maybe this
    > time will also be so?-)
    >
    > I want to measure how much memory a program allocates for itself. The
    > program only runs for a few seconds (constantly allocating more and more
    > memory during its runtime). Thus tools like 'top', 'pmap' or 'ps v' are
    > of no use. valgrind prints the summed amount of memory allocated by all
    > the mallocs executed by the program, which is larger than the actual
    > amount of memory used by the program (because the program also frees
    > memory from time to time). Thus it's not useful either.
    > '/usr/bin/time -f "%M"' was my most promising find, except that it
    > doesn't work (always prints "0").
    >
    > Any suggestions?


    # /usr/bin/time --version
    GNU time 1.7
    [root@p4_2400 ~ 15:13:27]#

    # /usr/bin/time -f "%Z" date
    Sun Apr 6 15:18:22 Local time zone must be set--see zic manual page 2008
    4096
    [root@p4_2400 ~ 15:18:22]#

    Or as good as it can get with use of GNU time
    # /usr/bin/time -v date
    Sun Apr 6 15:16:42 Local time zone must be set--see zic manual page 2008
    Command being timed: "date"
    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:00.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): 0
    Average resident set size (kbytes): 0
    Major (requiring I/O) page faults: 1
    Minor (reclaiming a frame) page faults: 200
    Voluntary context switches: 3
    Involuntary context switches: 2
    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
    [root@p4_2400 ~ 15:16:42]#

  5. Re: How to measure the memory usage of a program?

    >> If you're using kde try Ksysguard

    I used ksysguard it gives same results as ps -aux. The problem is that I want to measure the peak memory usage that is used by my C code. And if the program execution is just very few microseconds then how can I monitor the memory using ksysguard or ps.

    Thanks in advance.

+ Reply to Thread