Difference between free -m and ps -euf












6















I have a vps machine with ubuntu 10.04 and 512Mb of RAM. I'm trying to guess how much memory is available after running the mongodb daemon.



If I run free -m I get



             total       used       free     shared    buffers     cached
Mem: 496 489 6 0 4 452
-/+ buffers/cache: 33 462
Swap: 511 4 507


If I run ps euf I get



USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root 948 0.0 0.0 5928 472 tty6 Ss+ Aug25 0:00 /sbin/getty 384
root 947 0.0 0.0 5928 472 tty5 Ss+ Aug25 0:00 /sbin/getty 384
root 946 0.0 0.0 5928 472 tty4 Ss+ Aug25 0:00 /sbin/getty 384
root 945 0.0 0.0 5928 472 tty3 Ss+ Aug25 0:00 /sbin/getty 384
root 944 0.0 0.0 5928 472 tty2 Ss+ Aug25 0:00 /sbin/getty 384
root 943 0.0 0.1 51856 536 hvc0 Ss Aug25 0:00 /bin/login --
root 978 0.0 0.4 20580 2424 hvc0 S Aug25 0:01 _ -bash TERM=
root 7593 0.0 0.1 10332 524 hvc0 T Aug25 0:00 _ nano he
root 12576 0.7 3.1 122520 16220 hvc0 Sl 07:42 0:12 _ ./mongo
root 12599 0.0 0.2 16300 1060 hvc0 R+ 08:09 0:00 _ ps euf


So it seems that less than 5% of memory is used by processes but I have only 6Mb of free memory... why?










share|improve this question





























    6















    I have a vps machine with ubuntu 10.04 and 512Mb of RAM. I'm trying to guess how much memory is available after running the mongodb daemon.



    If I run free -m I get



                 total       used       free     shared    buffers     cached
    Mem: 496 489 6 0 4 452
    -/+ buffers/cache: 33 462
    Swap: 511 4 507


    If I run ps euf I get



    USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
    root 948 0.0 0.0 5928 472 tty6 Ss+ Aug25 0:00 /sbin/getty 384
    root 947 0.0 0.0 5928 472 tty5 Ss+ Aug25 0:00 /sbin/getty 384
    root 946 0.0 0.0 5928 472 tty4 Ss+ Aug25 0:00 /sbin/getty 384
    root 945 0.0 0.0 5928 472 tty3 Ss+ Aug25 0:00 /sbin/getty 384
    root 944 0.0 0.0 5928 472 tty2 Ss+ Aug25 0:00 /sbin/getty 384
    root 943 0.0 0.1 51856 536 hvc0 Ss Aug25 0:00 /bin/login --
    root 978 0.0 0.4 20580 2424 hvc0 S Aug25 0:01 _ -bash TERM=
    root 7593 0.0 0.1 10332 524 hvc0 T Aug25 0:00 _ nano he
    root 12576 0.7 3.1 122520 16220 hvc0 Sl 07:42 0:12 _ ./mongo
    root 12599 0.0 0.2 16300 1060 hvc0 R+ 08:09 0:00 _ ps euf


    So it seems that less than 5% of memory is used by processes but I have only 6Mb of free memory... why?










    share|improve this question



























      6












      6








      6








      I have a vps machine with ubuntu 10.04 and 512Mb of RAM. I'm trying to guess how much memory is available after running the mongodb daemon.



      If I run free -m I get



                   total       used       free     shared    buffers     cached
      Mem: 496 489 6 0 4 452
      -/+ buffers/cache: 33 462
      Swap: 511 4 507


      If I run ps euf I get



      USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
      root 948 0.0 0.0 5928 472 tty6 Ss+ Aug25 0:00 /sbin/getty 384
      root 947 0.0 0.0 5928 472 tty5 Ss+ Aug25 0:00 /sbin/getty 384
      root 946 0.0 0.0 5928 472 tty4 Ss+ Aug25 0:00 /sbin/getty 384
      root 945 0.0 0.0 5928 472 tty3 Ss+ Aug25 0:00 /sbin/getty 384
      root 944 0.0 0.0 5928 472 tty2 Ss+ Aug25 0:00 /sbin/getty 384
      root 943 0.0 0.1 51856 536 hvc0 Ss Aug25 0:00 /bin/login --
      root 978 0.0 0.4 20580 2424 hvc0 S Aug25 0:01 _ -bash TERM=
      root 7593 0.0 0.1 10332 524 hvc0 T Aug25 0:00 _ nano he
      root 12576 0.7 3.1 122520 16220 hvc0 Sl 07:42 0:12 _ ./mongo
      root 12599 0.0 0.2 16300 1060 hvc0 R+ 08:09 0:00 _ ps euf


      So it seems that less than 5% of memory is used by processes but I have only 6Mb of free memory... why?










      share|improve this question
















      I have a vps machine with ubuntu 10.04 and 512Mb of RAM. I'm trying to guess how much memory is available after running the mongodb daemon.



      If I run free -m I get



                   total       used       free     shared    buffers     cached
      Mem: 496 489 6 0 4 452
      -/+ buffers/cache: 33 462
      Swap: 511 4 507


      If I run ps euf I get



      USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
      root 948 0.0 0.0 5928 472 tty6 Ss+ Aug25 0:00 /sbin/getty 384
      root 947 0.0 0.0 5928 472 tty5 Ss+ Aug25 0:00 /sbin/getty 384
      root 946 0.0 0.0 5928 472 tty4 Ss+ Aug25 0:00 /sbin/getty 384
      root 945 0.0 0.0 5928 472 tty3 Ss+ Aug25 0:00 /sbin/getty 384
      root 944 0.0 0.0 5928 472 tty2 Ss+ Aug25 0:00 /sbin/getty 384
      root 943 0.0 0.1 51856 536 hvc0 Ss Aug25 0:00 /bin/login --
      root 978 0.0 0.4 20580 2424 hvc0 S Aug25 0:01 _ -bash TERM=
      root 7593 0.0 0.1 10332 524 hvc0 T Aug25 0:00 _ nano he
      root 12576 0.7 3.1 122520 16220 hvc0 Sl 07:42 0:12 _ ./mongo
      root 12599 0.0 0.2 16300 1060 hvc0 R+ 08:09 0:00 _ ps euf


      So it seems that less than 5% of memory is used by processes but I have only 6Mb of free memory... why?







      memory ps






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited 2 hours ago









      Rui F Ribeiro

      41.5k1483140




      41.5k1483140










      asked Aug 27 '11 at 15:11









      mamoomamoo

      1335




      1335






















          2 Answers
          2






          active

          oldest

          votes


















          10














          The buffers and cache are dynamically sized. If processes need more space, then it is taken from the buffers and the cache.



          The key is to look at the second line ("-/+ buffers/cache").



          Mem:           496        489          6          0          4        452
          -/+ buffers/cache: 33 462


          Notice that the free in the second line (462) is the sum of 6 (free), 4 (buffers) and 452 (cached). This is the real amount of free space. If this falls too low, then the system would start swapping processes out of memory to swap space.



          So in reality, you are using 33MB of memory and have available 462MB - probably slightly less since you would still need some buffers for i/o.






          share|improve this answer
























          • Great and clear explanation. Thanks!

            – mamoo
            Aug 27 '11 at 15:32



















          4














          Apart from the correct explanation by Arcege, there are also two other misconceptions hidden in your interpretation of ps euf.




          1. The command ps euf does not list all the processes - you should use ps axeuf for that.


          2. Percentages of used memory for each process are given, as you can see, rounded to 0.1%. So adding them up will give erroneous results - (roughly) all processes use some memory - even if it is less then 0.1%. If there are, for instance, 20 processes that use 0.05%, they'd add up to 1%, not 0%.







          share|improve this answer

























            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%2f19560%2fdifference-between-free-m-and-ps-euf%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            10














            The buffers and cache are dynamically sized. If processes need more space, then it is taken from the buffers and the cache.



            The key is to look at the second line ("-/+ buffers/cache").



            Mem:           496        489          6          0          4        452
            -/+ buffers/cache: 33 462


            Notice that the free in the second line (462) is the sum of 6 (free), 4 (buffers) and 452 (cached). This is the real amount of free space. If this falls too low, then the system would start swapping processes out of memory to swap space.



            So in reality, you are using 33MB of memory and have available 462MB - probably slightly less since you would still need some buffers for i/o.






            share|improve this answer
























            • Great and clear explanation. Thanks!

              – mamoo
              Aug 27 '11 at 15:32
















            10














            The buffers and cache are dynamically sized. If processes need more space, then it is taken from the buffers and the cache.



            The key is to look at the second line ("-/+ buffers/cache").



            Mem:           496        489          6          0          4        452
            -/+ buffers/cache: 33 462


            Notice that the free in the second line (462) is the sum of 6 (free), 4 (buffers) and 452 (cached). This is the real amount of free space. If this falls too low, then the system would start swapping processes out of memory to swap space.



            So in reality, you are using 33MB of memory and have available 462MB - probably slightly less since you would still need some buffers for i/o.






            share|improve this answer
























            • Great and clear explanation. Thanks!

              – mamoo
              Aug 27 '11 at 15:32














            10












            10








            10







            The buffers and cache are dynamically sized. If processes need more space, then it is taken from the buffers and the cache.



            The key is to look at the second line ("-/+ buffers/cache").



            Mem:           496        489          6          0          4        452
            -/+ buffers/cache: 33 462


            Notice that the free in the second line (462) is the sum of 6 (free), 4 (buffers) and 452 (cached). This is the real amount of free space. If this falls too low, then the system would start swapping processes out of memory to swap space.



            So in reality, you are using 33MB of memory and have available 462MB - probably slightly less since you would still need some buffers for i/o.






            share|improve this answer













            The buffers and cache are dynamically sized. If processes need more space, then it is taken from the buffers and the cache.



            The key is to look at the second line ("-/+ buffers/cache").



            Mem:           496        489          6          0          4        452
            -/+ buffers/cache: 33 462


            Notice that the free in the second line (462) is the sum of 6 (free), 4 (buffers) and 452 (cached). This is the real amount of free space. If this falls too low, then the system would start swapping processes out of memory to swap space.



            So in reality, you are using 33MB of memory and have available 462MB - probably slightly less since you would still need some buffers for i/o.







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Aug 27 '11 at 15:31









            ArcegeArcege

            17.3k44257




            17.3k44257













            • Great and clear explanation. Thanks!

              – mamoo
              Aug 27 '11 at 15:32



















            • Great and clear explanation. Thanks!

              – mamoo
              Aug 27 '11 at 15:32

















            Great and clear explanation. Thanks!

            – mamoo
            Aug 27 '11 at 15:32





            Great and clear explanation. Thanks!

            – mamoo
            Aug 27 '11 at 15:32













            4














            Apart from the correct explanation by Arcege, there are also two other misconceptions hidden in your interpretation of ps euf.




            1. The command ps euf does not list all the processes - you should use ps axeuf for that.


            2. Percentages of used memory for each process are given, as you can see, rounded to 0.1%. So adding them up will give erroneous results - (roughly) all processes use some memory - even if it is less then 0.1%. If there are, for instance, 20 processes that use 0.05%, they'd add up to 1%, not 0%.







            share|improve this answer






























              4














              Apart from the correct explanation by Arcege, there are also two other misconceptions hidden in your interpretation of ps euf.




              1. The command ps euf does not list all the processes - you should use ps axeuf for that.


              2. Percentages of used memory for each process are given, as you can see, rounded to 0.1%. So adding them up will give erroneous results - (roughly) all processes use some memory - even if it is less then 0.1%. If there are, for instance, 20 processes that use 0.05%, they'd add up to 1%, not 0%.







              share|improve this answer




























                4












                4








                4







                Apart from the correct explanation by Arcege, there are also two other misconceptions hidden in your interpretation of ps euf.




                1. The command ps euf does not list all the processes - you should use ps axeuf for that.


                2. Percentages of used memory for each process are given, as you can see, rounded to 0.1%. So adding them up will give erroneous results - (roughly) all processes use some memory - even if it is less then 0.1%. If there are, for instance, 20 processes that use 0.05%, they'd add up to 1%, not 0%.







                share|improve this answer















                Apart from the correct explanation by Arcege, there are also two other misconceptions hidden in your interpretation of ps euf.




                1. The command ps euf does not list all the processes - you should use ps axeuf for that.


                2. Percentages of used memory for each process are given, as you can see, rounded to 0.1%. So adding them up will give erroneous results - (roughly) all processes use some memory - even if it is less then 0.1%. If there are, for instance, 20 processes that use 0.05%, they'd add up to 1%, not 0%.








                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Apr 13 '17 at 12:36









                Community

                1




                1










                answered Aug 27 '11 at 21:43









                rozcietrzewiaczrozcietrzewiacz

                29.4k47392




                29.4k47392






























                    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%2f19560%2fdifference-between-free-m-and-ps-euf%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







                    Popular posts from this blog

                    CARDNET

                    Boot-repair Failure: Unable to locate package grub-common:i386

                    濃尾地震