peak memory usage - Unix

This is a discussion on peak memory usage - Unix ; Hi, What is the right tool to find the peak memory usage of a C++ program? I tried Valgrind but is does not seem to be able to answer my question. I know "top" shows the memory usage, but it ...

+ Reply to Thread
Results 1 to 7 of 7

Thread: peak memory usage

  1. peak memory usage

    Hi,

    What is the right tool to find the peak memory usage of a C++ program?

    I tried Valgrind but is does not seem to be able to answer my question.
    I know "top" shows the memory usage, but it shows it in real time and it
    is difficult to get the peak.

    Thanks a lot,
    Ray

  2. Re: peak memory usage

    Rares Vernica writes:
    > What is the right tool to find the peak memory usage of a C++ program?


    It depends on what operating system you are targetting.

    > I tried Valgrind but is does not seem to be able to answer my
    > question. I know "top" shows the memory usage, but it shows it in real
    > time and it is difficult to get the peak.


    Some UNIX systems have other tools too, i.e. on Solaris, you can use
    libumem.so.1 and mdb to track down memory usage with a lot of detail.

    - Giorgos


  3. Re: peak memory usage

    Giorgos Keramidas wrote:
    > Rares Vernica writes:
    >> What is the right tool to find the peak memory usage of a C++ program?

    >
    > It depends on what operating system you are targetting.
    >
    >> I tried Valgrind but is does not seem to be able to answer my
    >> question. I know "top" shows the memory usage, but it shows it in real
    >> time and it is difficult to get the peak.

    >
    > Some UNIX systems have other tools too, i.e. on Solaris, you can use
    > libumem.so.1 and mdb to track down memory usage with a lot of detail.
    >
    > - Giorgos
    >


    I am using Linux (Ubuntu).

    Thanks a lot,
    Ray

  4. Re: peak memory usage

    Rares Vernica writes:

    > What is the right tool to find the peak memory usage of a C++ program?
    >
    > I tried Valgrind but is does not seem to be able to answer my
    > question. I know "top" shows the memory usage, but it shows it in real
    > time and it is difficult to get the peak.


    Here is what Insure++ produces:

    $ cat junk.c
    #include
    int main(int argc, char *argv[])
    {
    size_t size = 100;
    size_t i;
    void *vp;

    if (1 < argc) size = atoi(argv[1]);
    vp = malloc(size);
    vp = realloc(vp, 2*size);
    free(vp);

    return 0;
    }

    $ insure gcc -g junk.c && ./a.out
    ************************** INSURE SUMMARY ************************* v7.1 **
    * Program : a.out *
    * Arguments : *
    * Directory : /home/paul *
    * Compiled on : Mar 20, 2007 21:37:26 *
    * Run on : Mar 20, 2007 21:39:13 *
    * Elapsed time : 00:00:00 *
    * Malloc HWM : 243 bytes *
    ************************************************** *************************
    .... some other stuff ...

    $ ./a.out 500 2>&1 | grep HWM
    * Malloc HWM : 1043 bytes (1K) *

    $ ./a.out 2000 2>&1 | grep HWM
    * Malloc HWM : 4043 bytes (3K) *

    Keeping track of malloc high-water-mark is a tiny fraction of what
    Insure can do ...

    Cheers,
    --
    In order to understand recursion you must first understand recursion.
    Remove /-nsp/ for email.

  5. Re: peak memory usage

    Paul Pluzhnikov wrote:
    > Rares Vernica writes:
    >
    >> What is the right tool to find the peak memory usage of a C++ program?
    >>
    >> I tried Valgrind but is does not seem to be able to answer my
    >> question. I know "top" shows the memory usage, but it shows it in real
    >> time and it is difficult to get the peak.

    >
    > Here is what Insure++ produces:
    >
    > $ cat junk.c
    > #include
    > int main(int argc, char *argv[])
    > {
    > size_t size = 100;
    > size_t i;
    > void *vp;
    >
    > if (1 < argc) size = atoi(argv[1]);
    > vp = malloc(size);
    > vp = realloc(vp, 2*size);
    > free(vp);
    >
    > return 0;
    > }
    >
    > $ insure gcc -g junk.c && ./a.out
    > ************************** INSURE SUMMARY ************************* v7.1 **
    > * Program : a.out *
    > * Arguments : *
    > * Directory : /home/paul *
    > * Compiled on : Mar 20, 2007 21:37:26 *
    > * Run on : Mar 20, 2007 21:39:13 *
    > * Elapsed time : 00:00:00 *
    > * Malloc HWM : 243 bytes *
    > ************************************************** *************************
    > ... some other stuff ...
    >
    > $ ./a.out 500 2>&1 | grep HWM
    > * Malloc HWM : 1043 bytes (1K) *
    >
    > $ ./a.out 2000 2>&1 | grep HWM
    > * Malloc HWM : 4043 bytes (3K) *
    >
    > Keeping track of malloc high-water-mark is a tiny fraction of what
    > Insure can do ...
    >
    > Cheers,


    Seems nice, but is not free.

    Thanks,
    Ray

  6. Re: peak memory usage

    Rares Vernica writes:

    >> Keeping track of malloc high-water-mark is a tiny fraction of what
    >> Insure can do ...

    >
    > Seems nice, but is not free.


    You never asked for "free" in your original post.
    You get what you ask for.

    Cheers,
    --
    In order to understand recursion you must first understand recursion.
    Remove /-nsp/ for email.

  7. Re: peak memory usage

    Rares Vernica wrote:
    > Hi,
    >
    > What is the right tool to find the peak memory usage of a C++ program?
    >
    > I tried Valgrind but is does not seem to be able to answer my question.
    > I know "top" shows the memory usage, but it shows it in real time and it
    > is difficult to get the peak.
    >
    > Thanks a lot,
    > Ray


    I wrote a tool for monitoring peaks in NetBSD. It should be fairly easy
    to port to other systems. It's much easier and more reliable to use a
    graph, than to watch numbers that change quickly.

    http://mini.net/tcl/14888

    I hope that helps.

    -George

+ Reply to Thread