The best way to view the memory consumed by a process under Linux __linux

Source: Internet
Author: User

Today, I saw StackOverflow on how to see how the memory of a process occupied by the answer, feel very good, but the whole English, many people may not understand, so I translate

Translated from http://stackoverflow.com/questions/3853655/in-linux-how-to-tell-how-much-memory-processes-are-using

The way you can view the memory consumed by a process may be more complicated than you might think. The best way I can find is in this article (https://web.archive.org/web/20101124103342/http://kdedevelopers.org/node/4040)

Echo 0 $ (awk '/type/{print + ", $} '/proc/' pidof PROCESS '/smaps) | Bc

Pidof processes are the process PID of the process you want to view. The optional values for type are as follows

Rss: Memory footprint. All memory consumed by the process, including the memory shared with other processes (directly adding the entire amount of memory shared). But this value does not contain swap shared: The memory privatethat the process shares with other processes: the private memory that the process occupies. With this data, you can see the memory leak problem swap The amount of memory Pss is proportional to the swap memory used by the process. This is a good look at the overall memory footprint of the parameters. This is the memory footprint that adjusts the amount of shared memory based on the number of shared processes. If a process occupies a private memory of 1MB, the shared memory used has 20MB, but this shared memory has 10 processes (including itself) in use, then PSS is 1 + 20/10 = 3MB

Translator by:

My own implementation of this code when I found that the BC tool is not installed, first use yum install BC to install the BC

I'm going to use PS aux | grep hbase to find the process number that HBase occupies

And this is my example of execution.

# echo 0 $ (awk '/pss/{print "+", $} '/proc/2871/smaps) | BC
186814


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.