Find out the total memory allocated for a particular process in Ubuntu












13














How can I find out the total memory allocated for a particular process in Ubuntu?










share|improve this question




















  • 1




    Have you tried ps -aefl and looked at the SZ column?
    – mdpc
    Aug 22 '14 at 5:30






  • 2




    What do you mean by “find out the memory allocated”? Do you want to know how much memory the process is using?
    – Gilles
    Aug 22 '14 at 22:03
















13














How can I find out the total memory allocated for a particular process in Ubuntu?










share|improve this question




















  • 1




    Have you tried ps -aefl and looked at the SZ column?
    – mdpc
    Aug 22 '14 at 5:30






  • 2




    What do you mean by “find out the memory allocated”? Do you want to know how much memory the process is using?
    – Gilles
    Aug 22 '14 at 22:03














13












13








13


2





How can I find out the total memory allocated for a particular process in Ubuntu?










share|improve this question















How can I find out the total memory allocated for a particular process in Ubuntu?







linux process memory






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Dec 11 at 11:18









anishpatel

1033




1033










asked Aug 22 '14 at 5:13









Anjali

69113




69113








  • 1




    Have you tried ps -aefl and looked at the SZ column?
    – mdpc
    Aug 22 '14 at 5:30






  • 2




    What do you mean by “find out the memory allocated”? Do you want to know how much memory the process is using?
    – Gilles
    Aug 22 '14 at 22:03














  • 1




    Have you tried ps -aefl and looked at the SZ column?
    – mdpc
    Aug 22 '14 at 5:30






  • 2




    What do you mean by “find out the memory allocated”? Do you want to know how much memory the process is using?
    – Gilles
    Aug 22 '14 at 22:03








1




1




Have you tried ps -aefl and looked at the SZ column?
– mdpc
Aug 22 '14 at 5:30




Have you tried ps -aefl and looked at the SZ column?
– mdpc
Aug 22 '14 at 5:30




2




2




What do you mean by “find out the memory allocated”? Do you want to know how much memory the process is using?
– Gilles
Aug 22 '14 at 22:03




What do you mean by “find out the memory allocated”? Do you want to know how much memory the process is using?
– Gilles
Aug 22 '14 at 22:03










3 Answers
3






active

oldest

votes


















12














Try:



pidof bash | xargs ps -o rss,sz,vsz


To find the memory usage of your current bash shell (assuming you're using bash). Change bash to whatever you're investigating. If you're after one specific process, simply use on it's own:



ps -o rss,sz,vsz <process id>


From the man page:



RSS: resident set size, the non-swapped physical memory that a task has used (in kiloBytes).



SZ: size in physical pages of the core image of the process. This includes text, data, and stack space.



VSZ: virtual memory size of the process in KiB (1024-byte units).



The man page for ps will list all the possible arguments to the -o option (there are quite a few to choose from). Instead of -o rss,sz you could use the BSD style v option (no dash) which shows an alternative memory layout.






share|improve this answer























  • Thanks gareth... Are you saying that SZ is the memory allocated for that process?
    – Anjali
    Aug 22 '14 at 6:30








  • 4




    There's a good QA here that explains the relationship between RSS, SZ and VSZ.
    – garethTheRed
    Aug 22 '14 at 7:03



















5














You can use pmap which shows the memory map of a process:



pmap -p pid


For more information about it see the man page man pmap or have a look at pmap(1): report memory map of process - Linux man page.






share|improve this answer





























    0















    how to find out the total memory allocated for a particular process in ubuntu?




    You don't define what is the memory allocated for a process, and actually that is a pretty complex question (what about shared memory mappings - see mmap(2) for details; what about POSIX shared memory - see shm_overview(7) for more; what about some pages in the page cache used for opened files; etc...)



    You could use the /proc/ file system (which BTW is used by ps, pmap, top, htop etc....). Read proc(5) for more. In particular for process of pid 1234 you could use /proc/1234/status, /proc/1234/statm, /proc/1234/maps etc... They are all textual pseudo-files (a bit like pipes) that you can see with cat (or read sequentially inside some program). BTW, from inside a program you might use /proc/self (which is a pseudo symlink), e.g. read sequentially /proc/self/status etc...



    See also LinuxAteMyRam.






    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%2f151510%2ffind-out-the-total-memory-allocated-for-a-particular-process-in-ubuntu%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









      12














      Try:



      pidof bash | xargs ps -o rss,sz,vsz


      To find the memory usage of your current bash shell (assuming you're using bash). Change bash to whatever you're investigating. If you're after one specific process, simply use on it's own:



      ps -o rss,sz,vsz <process id>


      From the man page:



      RSS: resident set size, the non-swapped physical memory that a task has used (in kiloBytes).



      SZ: size in physical pages of the core image of the process. This includes text, data, and stack space.



      VSZ: virtual memory size of the process in KiB (1024-byte units).



      The man page for ps will list all the possible arguments to the -o option (there are quite a few to choose from). Instead of -o rss,sz you could use the BSD style v option (no dash) which shows an alternative memory layout.






      share|improve this answer























      • Thanks gareth... Are you saying that SZ is the memory allocated for that process?
        – Anjali
        Aug 22 '14 at 6:30








      • 4




        There's a good QA here that explains the relationship between RSS, SZ and VSZ.
        – garethTheRed
        Aug 22 '14 at 7:03
















      12














      Try:



      pidof bash | xargs ps -o rss,sz,vsz


      To find the memory usage of your current bash shell (assuming you're using bash). Change bash to whatever you're investigating. If you're after one specific process, simply use on it's own:



      ps -o rss,sz,vsz <process id>


      From the man page:



      RSS: resident set size, the non-swapped physical memory that a task has used (in kiloBytes).



      SZ: size in physical pages of the core image of the process. This includes text, data, and stack space.



      VSZ: virtual memory size of the process in KiB (1024-byte units).



      The man page for ps will list all the possible arguments to the -o option (there are quite a few to choose from). Instead of -o rss,sz you could use the BSD style v option (no dash) which shows an alternative memory layout.






      share|improve this answer























      • Thanks gareth... Are you saying that SZ is the memory allocated for that process?
        – Anjali
        Aug 22 '14 at 6:30








      • 4




        There's a good QA here that explains the relationship between RSS, SZ and VSZ.
        – garethTheRed
        Aug 22 '14 at 7:03














      12












      12








      12






      Try:



      pidof bash | xargs ps -o rss,sz,vsz


      To find the memory usage of your current bash shell (assuming you're using bash). Change bash to whatever you're investigating. If you're after one specific process, simply use on it's own:



      ps -o rss,sz,vsz <process id>


      From the man page:



      RSS: resident set size, the non-swapped physical memory that a task has used (in kiloBytes).



      SZ: size in physical pages of the core image of the process. This includes text, data, and stack space.



      VSZ: virtual memory size of the process in KiB (1024-byte units).



      The man page for ps will list all the possible arguments to the -o option (there are quite a few to choose from). Instead of -o rss,sz you could use the BSD style v option (no dash) which shows an alternative memory layout.






      share|improve this answer














      Try:



      pidof bash | xargs ps -o rss,sz,vsz


      To find the memory usage of your current bash shell (assuming you're using bash). Change bash to whatever you're investigating. If you're after one specific process, simply use on it's own:



      ps -o rss,sz,vsz <process id>


      From the man page:



      RSS: resident set size, the non-swapped physical memory that a task has used (in kiloBytes).



      SZ: size in physical pages of the core image of the process. This includes text, data, and stack space.



      VSZ: virtual memory size of the process in KiB (1024-byte units).



      The man page for ps will list all the possible arguments to the -o option (there are quite a few to choose from). Instead of -o rss,sz you could use the BSD style v option (no dash) which shows an alternative memory layout.







      share|improve this answer














      share|improve this answer



      share|improve this answer








      edited Aug 22 '14 at 7:01

























      answered Aug 22 '14 at 5:48









      garethTheRed

      23.9k36079




      23.9k36079












      • Thanks gareth... Are you saying that SZ is the memory allocated for that process?
        – Anjali
        Aug 22 '14 at 6:30








      • 4




        There's a good QA here that explains the relationship between RSS, SZ and VSZ.
        – garethTheRed
        Aug 22 '14 at 7:03


















      • Thanks gareth... Are you saying that SZ is the memory allocated for that process?
        – Anjali
        Aug 22 '14 at 6:30








      • 4




        There's a good QA here that explains the relationship between RSS, SZ and VSZ.
        – garethTheRed
        Aug 22 '14 at 7:03
















      Thanks gareth... Are you saying that SZ is the memory allocated for that process?
      – Anjali
      Aug 22 '14 at 6:30






      Thanks gareth... Are you saying that SZ is the memory allocated for that process?
      – Anjali
      Aug 22 '14 at 6:30






      4




      4




      There's a good QA here that explains the relationship between RSS, SZ and VSZ.
      – garethTheRed
      Aug 22 '14 at 7:03




      There's a good QA here that explains the relationship between RSS, SZ and VSZ.
      – garethTheRed
      Aug 22 '14 at 7:03













      5














      You can use pmap which shows the memory map of a process:



      pmap -p pid


      For more information about it see the man page man pmap or have a look at pmap(1): report memory map of process - Linux man page.






      share|improve this answer


























        5














        You can use pmap which shows the memory map of a process:



        pmap -p pid


        For more information about it see the man page man pmap or have a look at pmap(1): report memory map of process - Linux man page.






        share|improve this answer
























          5












          5








          5






          You can use pmap which shows the memory map of a process:



          pmap -p pid


          For more information about it see the man page man pmap or have a look at pmap(1): report memory map of process - Linux man page.






          share|improve this answer












          You can use pmap which shows the memory map of a process:



          pmap -p pid


          For more information about it see the man page man pmap or have a look at pmap(1): report memory map of process - Linux man page.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Aug 22 '14 at 8:04









          ByteNudger

          659616




          659616























              0















              how to find out the total memory allocated for a particular process in ubuntu?




              You don't define what is the memory allocated for a process, and actually that is a pretty complex question (what about shared memory mappings - see mmap(2) for details; what about POSIX shared memory - see shm_overview(7) for more; what about some pages in the page cache used for opened files; etc...)



              You could use the /proc/ file system (which BTW is used by ps, pmap, top, htop etc....). Read proc(5) for more. In particular for process of pid 1234 you could use /proc/1234/status, /proc/1234/statm, /proc/1234/maps etc... They are all textual pseudo-files (a bit like pipes) that you can see with cat (or read sequentially inside some program). BTW, from inside a program you might use /proc/self (which is a pseudo symlink), e.g. read sequentially /proc/self/status etc...



              See also LinuxAteMyRam.






              share|improve this answer




























                0















                how to find out the total memory allocated for a particular process in ubuntu?




                You don't define what is the memory allocated for a process, and actually that is a pretty complex question (what about shared memory mappings - see mmap(2) for details; what about POSIX shared memory - see shm_overview(7) for more; what about some pages in the page cache used for opened files; etc...)



                You could use the /proc/ file system (which BTW is used by ps, pmap, top, htop etc....). Read proc(5) for more. In particular for process of pid 1234 you could use /proc/1234/status, /proc/1234/statm, /proc/1234/maps etc... They are all textual pseudo-files (a bit like pipes) that you can see with cat (or read sequentially inside some program). BTW, from inside a program you might use /proc/self (which is a pseudo symlink), e.g. read sequentially /proc/self/status etc...



                See also LinuxAteMyRam.






                share|improve this answer


























                  0












                  0








                  0







                  how to find out the total memory allocated for a particular process in ubuntu?




                  You don't define what is the memory allocated for a process, and actually that is a pretty complex question (what about shared memory mappings - see mmap(2) for details; what about POSIX shared memory - see shm_overview(7) for more; what about some pages in the page cache used for opened files; etc...)



                  You could use the /proc/ file system (which BTW is used by ps, pmap, top, htop etc....). Read proc(5) for more. In particular for process of pid 1234 you could use /proc/1234/status, /proc/1234/statm, /proc/1234/maps etc... They are all textual pseudo-files (a bit like pipes) that you can see with cat (or read sequentially inside some program). BTW, from inside a program you might use /proc/self (which is a pseudo symlink), e.g. read sequentially /proc/self/status etc...



                  See also LinuxAteMyRam.






                  share|improve this answer















                  how to find out the total memory allocated for a particular process in ubuntu?




                  You don't define what is the memory allocated for a process, and actually that is a pretty complex question (what about shared memory mappings - see mmap(2) for details; what about POSIX shared memory - see shm_overview(7) for more; what about some pages in the page cache used for opened files; etc...)



                  You could use the /proc/ file system (which BTW is used by ps, pmap, top, htop etc....). Read proc(5) for more. In particular for process of pid 1234 you could use /proc/1234/status, /proc/1234/statm, /proc/1234/maps etc... They are all textual pseudo-files (a bit like pipes) that you can see with cat (or read sequentially inside some program). BTW, from inside a program you might use /proc/self (which is a pseudo symlink), e.g. read sequentially /proc/self/status etc...



                  See also LinuxAteMyRam.







                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited Aug 21 '17 at 8:19

























                  answered Aug 21 '17 at 8:03









                  Basile Starynkevitch

                  8,0412041




                  8,0412041






























                      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.





                      Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                      Please pay close attention to the following guidance:


                      • 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%2f151510%2ffind-out-the-total-memory-allocated-for-a-particular-process-in-ubuntu%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

                      Morgemoulin

                      Scott Moir

                      Souastre