Determining maximum memory usage for an extremely short process Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern) 2019 Community Moderator Election Results Why I closed the “Why is Kali so hard” questionNeed explanation on Resident Set Size/Virtual SizeHow to get the maximum virtual set size of a unix process during its lifetime?How to know maximum memory usage of a process?Program stall under user but runs under rootprocess memory usageFedora 20 memory.limit_in_bytes not workingActual memory usage of a processProcess killed by OOM killer when plenty of memory apparently freeHow does an OS detect an access to random memory address of a compiled program?Low-level Process analysis for getting instruction size, runnable dependencies

What do you call the holes in a flute?

Autumning in love

Choo-choo! Word trains

What do you call a plan that's an alternative plan in case your initial plan fails?

When is phishing education going too far?

Simulating Exploding Dice

Can a monk deflect thrown melee weapons?

Active filter with series inductor and resistor - do these exist?

Why is there no army of Iron-Mans in the MCU?

Stop battery usage [Ubuntu 18]

Why don't the Weasley twins use magic outside of school if the Trace can only find the location of spells cast?

How can I make names more distinctive without making them longer?

What is the order of Mitzvot in Rambam's Sefer Hamitzvot?

If A makes B more likely then B makes A more likely"

Blender game recording at the wrong time

When communicating altitude with a '9' in it, should it be pronounced "nine hundred" or "niner hundred"?

Passing functions in C++

Why does this iterative way of solving of equation work?

How to say 'striped' in Latin

What can I do if my MacBook isn’t charging but already ran out?

Using "nakedly" instead of "with nothing on"

3 doors, three guards, one stone

New Order #5: where Fibonacci and Beatty meet at Wythoff

How to say that you spent the night with someone, you were only sleeping and nothing else?



Determining maximum memory usage for an extremely short process



Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)
2019 Community Moderator Election Results
Why I closed the “Why is Kali so hard” questionNeed explanation on Resident Set Size/Virtual SizeHow to get the maximum virtual set size of a unix process during its lifetime?How to know maximum memory usage of a process?Program stall under user but runs under rootprocess memory usageFedora 20 memory.limit_in_bytes not workingActual memory usage of a processProcess killed by OOM killer when plenty of memory apparently freeHow does an OS detect an access to random memory address of a compiled program?Low-level Process analysis for getting instruction size, runnable dependencies



.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








6















I have a program I am testing and I need to determine the maximum memory used by the process.
I know that in general
ps -aux
can give me this information, but the process runs in under 1/10 seconds so getting ps to catch it isn't a good option.



Are there any other good options for getting this kind of information?
I am running some benchmarks on a program to see if I can improve its memory usage.










share|improve this question
























  • Run it under a debugger and set a breakpoint?

    – Celada
    Apr 11 '15 at 20:55

















6















I have a program I am testing and I need to determine the maximum memory used by the process.
I know that in general
ps -aux
can give me this information, but the process runs in under 1/10 seconds so getting ps to catch it isn't a good option.



Are there any other good options for getting this kind of information?
I am running some benchmarks on a program to see if I can improve its memory usage.










share|improve this question
























  • Run it under a debugger and set a breakpoint?

    – Celada
    Apr 11 '15 at 20:55













6












6








6








I have a program I am testing and I need to determine the maximum memory used by the process.
I know that in general
ps -aux
can give me this information, but the process runs in under 1/10 seconds so getting ps to catch it isn't a good option.



Are there any other good options for getting this kind of information?
I am running some benchmarks on a program to see if I can improve its memory usage.










share|improve this question
















I have a program I am testing and I need to determine the maximum memory used by the process.
I know that in general
ps -aux
can give me this information, but the process runs in under 1/10 seconds so getting ps to catch it isn't a good option.



Are there any other good options for getting this kind of information?
I am running some benchmarks on a program to see if I can improve its memory usage.







process memory






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Apr 11 '15 at 22:14









Gilles

548k13011131631




548k13011131631










asked Apr 11 '15 at 20:50









dnraikesdnraikes

73126




73126












  • Run it under a debugger and set a breakpoint?

    – Celada
    Apr 11 '15 at 20:55

















  • Run it under a debugger and set a breakpoint?

    – Celada
    Apr 11 '15 at 20:55
















Run it under a debugger and set a breakpoint?

– Celada
Apr 11 '15 at 20:55





Run it under a debugger and set a breakpoint?

– Celada
Apr 11 '15 at 20:55










3 Answers
3






active

oldest

votes


















4














valgrind will give you this information, along with a number of other statistics on memory use (and it will tell you about memory leaks etc.). It will slow the program down somewhat, but since yours is a short-lived process it shouldn't be an issue.



Here's example output from running ls:



==7051== 
==7051== HEAP SUMMARY:
==7051== in use at exit: 351,689 bytes in 838 blocks
==7051== total heap usage: 1,049 allocs, 211 frees, 688,325 bytes allocated
==7051==
==7051== LEAK SUMMARY:
==7051== definitely lost: 0 bytes in 0 blocks
==7051== indirectly lost: 0 bytes in 0 blocks
==7051== possibly lost: 0 bytes in 0 blocks
==7051== still reachable: 351,689 bytes in 838 blocks
==7051== suppressed: 0 bytes in 0 blocks
==7051== Rerun with --leak-check=full to see details of leaked memory
==7051==
==7051== For counts of detected and suppressed errors, rerun with: -v
==7051== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)


The specific information you're looking for is given by the "total heap usage" line.






share|improve this answer






























    3














    Use GNU time (which has many more features that the builtin's "time" from bash) :



    $ sudo apt-get install time
    $ time prog >/dev/null
    0.00user 0.00system 0:00.00elapsed 0%CPU (0avgtext+0avgdata 2380maxresident)k
    0inputs+0outputs (0major+119minor)pagefaults 0swaps


    The time escaping explicitly asks not to use the builtin, /usr/bin/time would work too. There are many more display possibilites, use 'man time'.






    share|improve this answer






























      2














      This is an old thread, but I've just come across it when I also needed to check the memory requirements of a short running processes.



      I've done some investigating and the accepted answer appears to be incorrect. The OP and myself are trying to find the maximum amount of memory that will be used at any point by the program, the peak memory demand.



      The total heap usage metric from valgrind does not measure this, it instead measures the total of all allocations during execution. So if there were 100 iterations of a loop which allocated and then freed 1MB this would contribute 100MB to the total heap usage metric even though the peak memory demand of this is only 1MB.



      Valgrind does include a tool massif which can be used to find the peak memory demand of a program, which can visualised using the massif-visualizer tool:



      valgrind --tool=massif ./<your program>

      massif-visualizer massif.out.<num>


      This tool will plot amongst other things the total heap usage over time, and identifies the correct peak heap demand of the program. This process is described in more detail here.






      share|improve this answer








      New contributor




      PeteBlackerThe3rd is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.




















        Your Answer








        StackExchange.ready(function()
        var channelOptions =
        tags: "".split(" "),
        id: "106"
        ;
        initTagRenderer("".split(" "), "".split(" "), channelOptions);

        StackExchange.using("externalEditor", function()
        // Have to fire editor after snippets, if snippets enabled
        if (StackExchange.settings.snippets.snippetsEnabled)
        StackExchange.using("snippets", function()
        createEditor();
        );

        else
        createEditor();

        );

        function createEditor()
        StackExchange.prepareEditor(
        heartbeatType: 'answer',
        autoActivateHeartbeat: false,
        convertImagesToLinks: false,
        noModals: true,
        showLowRepImageUploadWarning: true,
        reputationToPostImages: null,
        bindNavPrevention: true,
        postfix: "",
        imageUploader:
        brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
        contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
        allowUrls: true
        ,
        onDemand: true,
        discardSelector: ".discard-answer"
        ,immediatelyShowMarkdownHelp:true
        );



        );













        draft saved

        draft discarded


















        StackExchange.ready(
        function ()
        StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f195684%2fdetermining-maximum-memory-usage-for-an-extremely-short-process%23new-answer', 'question_page');

        );

        Post as a guest















        Required, but never shown

























        3 Answers
        3






        active

        oldest

        votes








        3 Answers
        3






        active

        oldest

        votes









        active

        oldest

        votes






        active

        oldest

        votes









        4














        valgrind will give you this information, along with a number of other statistics on memory use (and it will tell you about memory leaks etc.). It will slow the program down somewhat, but since yours is a short-lived process it shouldn't be an issue.



        Here's example output from running ls:



        ==7051== 
        ==7051== HEAP SUMMARY:
        ==7051== in use at exit: 351,689 bytes in 838 blocks
        ==7051== total heap usage: 1,049 allocs, 211 frees, 688,325 bytes allocated
        ==7051==
        ==7051== LEAK SUMMARY:
        ==7051== definitely lost: 0 bytes in 0 blocks
        ==7051== indirectly lost: 0 bytes in 0 blocks
        ==7051== possibly lost: 0 bytes in 0 blocks
        ==7051== still reachable: 351,689 bytes in 838 blocks
        ==7051== suppressed: 0 bytes in 0 blocks
        ==7051== Rerun with --leak-check=full to see details of leaked memory
        ==7051==
        ==7051== For counts of detected and suppressed errors, rerun with: -v
        ==7051== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)


        The specific information you're looking for is given by the "total heap usage" line.






        share|improve this answer



























          4














          valgrind will give you this information, along with a number of other statistics on memory use (and it will tell you about memory leaks etc.). It will slow the program down somewhat, but since yours is a short-lived process it shouldn't be an issue.



          Here's example output from running ls:



          ==7051== 
          ==7051== HEAP SUMMARY:
          ==7051== in use at exit: 351,689 bytes in 838 blocks
          ==7051== total heap usage: 1,049 allocs, 211 frees, 688,325 bytes allocated
          ==7051==
          ==7051== LEAK SUMMARY:
          ==7051== definitely lost: 0 bytes in 0 blocks
          ==7051== indirectly lost: 0 bytes in 0 blocks
          ==7051== possibly lost: 0 bytes in 0 blocks
          ==7051== still reachable: 351,689 bytes in 838 blocks
          ==7051== suppressed: 0 bytes in 0 blocks
          ==7051== Rerun with --leak-check=full to see details of leaked memory
          ==7051==
          ==7051== For counts of detected and suppressed errors, rerun with: -v
          ==7051== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)


          The specific information you're looking for is given by the "total heap usage" line.






          share|improve this answer

























            4












            4








            4







            valgrind will give you this information, along with a number of other statistics on memory use (and it will tell you about memory leaks etc.). It will slow the program down somewhat, but since yours is a short-lived process it shouldn't be an issue.



            Here's example output from running ls:



            ==7051== 
            ==7051== HEAP SUMMARY:
            ==7051== in use at exit: 351,689 bytes in 838 blocks
            ==7051== total heap usage: 1,049 allocs, 211 frees, 688,325 bytes allocated
            ==7051==
            ==7051== LEAK SUMMARY:
            ==7051== definitely lost: 0 bytes in 0 blocks
            ==7051== indirectly lost: 0 bytes in 0 blocks
            ==7051== possibly lost: 0 bytes in 0 blocks
            ==7051== still reachable: 351,689 bytes in 838 blocks
            ==7051== suppressed: 0 bytes in 0 blocks
            ==7051== Rerun with --leak-check=full to see details of leaked memory
            ==7051==
            ==7051== For counts of detected and suppressed errors, rerun with: -v
            ==7051== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)


            The specific information you're looking for is given by the "total heap usage" line.






            share|improve this answer













            valgrind will give you this information, along with a number of other statistics on memory use (and it will tell you about memory leaks etc.). It will slow the program down somewhat, but since yours is a short-lived process it shouldn't be an issue.



            Here's example output from running ls:



            ==7051== 
            ==7051== HEAP SUMMARY:
            ==7051== in use at exit: 351,689 bytes in 838 blocks
            ==7051== total heap usage: 1,049 allocs, 211 frees, 688,325 bytes allocated
            ==7051==
            ==7051== LEAK SUMMARY:
            ==7051== definitely lost: 0 bytes in 0 blocks
            ==7051== indirectly lost: 0 bytes in 0 blocks
            ==7051== possibly lost: 0 bytes in 0 blocks
            ==7051== still reachable: 351,689 bytes in 838 blocks
            ==7051== suppressed: 0 bytes in 0 blocks
            ==7051== Rerun with --leak-check=full to see details of leaked memory
            ==7051==
            ==7051== For counts of detected and suppressed errors, rerun with: -v
            ==7051== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)


            The specific information you're looking for is given by the "total heap usage" line.







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Apr 11 '15 at 21:26









            Stephen KittStephen Kitt

            181k25415494




            181k25415494























                3














                Use GNU time (which has many more features that the builtin's "time" from bash) :



                $ sudo apt-get install time
                $ time prog >/dev/null
                0.00user 0.00system 0:00.00elapsed 0%CPU (0avgtext+0avgdata 2380maxresident)k
                0inputs+0outputs (0major+119minor)pagefaults 0swaps


                The time escaping explicitly asks not to use the builtin, /usr/bin/time would work too. There are many more display possibilites, use 'man time'.






                share|improve this answer



























                  3














                  Use GNU time (which has many more features that the builtin's "time" from bash) :



                  $ sudo apt-get install time
                  $ time prog >/dev/null
                  0.00user 0.00system 0:00.00elapsed 0%CPU (0avgtext+0avgdata 2380maxresident)k
                  0inputs+0outputs (0major+119minor)pagefaults 0swaps


                  The time escaping explicitly asks not to use the builtin, /usr/bin/time would work too. There are many more display possibilites, use 'man time'.






                  share|improve this answer

























                    3












                    3








                    3







                    Use GNU time (which has many more features that the builtin's "time" from bash) :



                    $ sudo apt-get install time
                    $ time prog >/dev/null
                    0.00user 0.00system 0:00.00elapsed 0%CPU (0avgtext+0avgdata 2380maxresident)k
                    0inputs+0outputs (0major+119minor)pagefaults 0swaps


                    The time escaping explicitly asks not to use the builtin, /usr/bin/time would work too. There are many more display possibilites, use 'man time'.






                    share|improve this answer













                    Use GNU time (which has many more features that the builtin's "time" from bash) :



                    $ sudo apt-get install time
                    $ time prog >/dev/null
                    0.00user 0.00system 0:00.00elapsed 0%CPU (0avgtext+0avgdata 2380maxresident)k
                    0inputs+0outputs (0major+119minor)pagefaults 0swaps


                    The time escaping explicitly asks not to use the builtin, /usr/bin/time would work too. There are many more display possibilites, use 'man time'.







                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered Apr 12 '15 at 15:13









                    zerodeuxzerodeux

                    1862




                    1862





















                        2














                        This is an old thread, but I've just come across it when I also needed to check the memory requirements of a short running processes.



                        I've done some investigating and the accepted answer appears to be incorrect. The OP and myself are trying to find the maximum amount of memory that will be used at any point by the program, the peak memory demand.



                        The total heap usage metric from valgrind does not measure this, it instead measures the total of all allocations during execution. So if there were 100 iterations of a loop which allocated and then freed 1MB this would contribute 100MB to the total heap usage metric even though the peak memory demand of this is only 1MB.



                        Valgrind does include a tool massif which can be used to find the peak memory demand of a program, which can visualised using the massif-visualizer tool:



                        valgrind --tool=massif ./<your program>

                        massif-visualizer massif.out.<num>


                        This tool will plot amongst other things the total heap usage over time, and identifies the correct peak heap demand of the program. This process is described in more detail here.






                        share|improve this answer








                        New contributor




                        PeteBlackerThe3rd is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                        Check out our Code of Conduct.
























                          2














                          This is an old thread, but I've just come across it when I also needed to check the memory requirements of a short running processes.



                          I've done some investigating and the accepted answer appears to be incorrect. The OP and myself are trying to find the maximum amount of memory that will be used at any point by the program, the peak memory demand.



                          The total heap usage metric from valgrind does not measure this, it instead measures the total of all allocations during execution. So if there were 100 iterations of a loop which allocated and then freed 1MB this would contribute 100MB to the total heap usage metric even though the peak memory demand of this is only 1MB.



                          Valgrind does include a tool massif which can be used to find the peak memory demand of a program, which can visualised using the massif-visualizer tool:



                          valgrind --tool=massif ./<your program>

                          massif-visualizer massif.out.<num>


                          This tool will plot amongst other things the total heap usage over time, and identifies the correct peak heap demand of the program. This process is described in more detail here.






                          share|improve this answer








                          New contributor




                          PeteBlackerThe3rd is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                          Check out our Code of Conduct.






















                            2












                            2








                            2







                            This is an old thread, but I've just come across it when I also needed to check the memory requirements of a short running processes.



                            I've done some investigating and the accepted answer appears to be incorrect. The OP and myself are trying to find the maximum amount of memory that will be used at any point by the program, the peak memory demand.



                            The total heap usage metric from valgrind does not measure this, it instead measures the total of all allocations during execution. So if there were 100 iterations of a loop which allocated and then freed 1MB this would contribute 100MB to the total heap usage metric even though the peak memory demand of this is only 1MB.



                            Valgrind does include a tool massif which can be used to find the peak memory demand of a program, which can visualised using the massif-visualizer tool:



                            valgrind --tool=massif ./<your program>

                            massif-visualizer massif.out.<num>


                            This tool will plot amongst other things the total heap usage over time, and identifies the correct peak heap demand of the program. This process is described in more detail here.






                            share|improve this answer








                            New contributor




                            PeteBlackerThe3rd is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                            Check out our Code of Conduct.










                            This is an old thread, but I've just come across it when I also needed to check the memory requirements of a short running processes.



                            I've done some investigating and the accepted answer appears to be incorrect. The OP and myself are trying to find the maximum amount of memory that will be used at any point by the program, the peak memory demand.



                            The total heap usage metric from valgrind does not measure this, it instead measures the total of all allocations during execution. So if there were 100 iterations of a loop which allocated and then freed 1MB this would contribute 100MB to the total heap usage metric even though the peak memory demand of this is only 1MB.



                            Valgrind does include a tool massif which can be used to find the peak memory demand of a program, which can visualised using the massif-visualizer tool:



                            valgrind --tool=massif ./<your program>

                            massif-visualizer massif.out.<num>


                            This tool will plot amongst other things the total heap usage over time, and identifies the correct peak heap demand of the program. This process is described in more detail here.







                            share|improve this answer








                            New contributor




                            PeteBlackerThe3rd is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                            Check out our Code of Conduct.









                            share|improve this answer



                            share|improve this answer






                            New contributor




                            PeteBlackerThe3rd is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                            Check out our Code of Conduct.









                            answered 18 hours ago









                            PeteBlackerThe3rdPeteBlackerThe3rd

                            212




                            212




                            New contributor




                            PeteBlackerThe3rd is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                            Check out our Code of Conduct.





                            New contributor





                            PeteBlackerThe3rd is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                            Check out our Code of Conduct.






                            PeteBlackerThe3rd is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                            Check out our Code of Conduct.



























                                draft saved

                                draft discarded
















































                                Thanks for contributing an answer to Unix & Linux Stack Exchange!


                                • Please be sure to answer the question. Provide details and share your research!

                                But avoid


                                • Asking for help, clarification, or responding to other answers.

                                • Making statements based on opinion; back them up with references or personal experience.

                                To learn more, see our tips on writing great answers.




                                draft saved


                                draft discarded














                                StackExchange.ready(
                                function ()
                                StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f195684%2fdetermining-maximum-memory-usage-for-an-extremely-short-process%23new-answer', 'question_page');

                                );

                                Post as a guest















                                Required, but never shown





















































                                Required, but never shown














                                Required, but never shown












                                Required, but never shown







                                Required, but never shown

































                                Required, but never shown














                                Required, but never shown












                                Required, but never shown







                                Required, but never shown







                                -memory, process

                                Popular posts from this blog

                                Frič See also Navigation menuinternal link

                                Identify plant with long narrow paired leaves and reddish stems Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern) Announcing the arrival of Valued Associate #679: Cesar Manara Unicorn Meta Zoo #1: Why another podcast?What is this plant with long sharp leaves? Is it a weed?What is this 3ft high, stalky plant, with mid sized narrow leaves?What is this young shrub with opposite ovate, crenate leaves and reddish stems?What is this plant with large broad serrated leaves?Identify this upright branching weed with long leaves and reddish stemsPlease help me identify this bulbous plant with long, broad leaves and white flowersWhat is this small annual with narrow gray/green leaves and rust colored daisy-type flowers?What is this chilli plant?Does anyone know what type of chilli plant this is?Help identify this plant

                                fontconfig warning: “/etc/fonts/fonts.conf”, line 100: unknown “element blank” The 2019 Stack Overflow Developer Survey Results Are In“tar: unrecognized option --warning” during 'apt-get install'How to fix Fontconfig errorHow do I figure out which font file is chosen for a system generic font alias?Why are some apt-get-installed fonts being ignored by fc-list, xfontsel, etc?Reload settings in /etc/fonts/conf.dTaking 30 seconds longer to boot after upgrade from jessie to stretchHow to match multiple font names with a single <match> element?Adding a custom font to fontconfigRemoving fonts from fontconfig <match> resultsBroken fonts after upgrading Firefox ESR to latest Firefox