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