2016年1月28日 星期四

[Linux 文章收集] Linux find the memory used by a program / process using pmap command

Source From Here
Introduction
You can find the memory used by a program (process) by looking into /proc directory or using standard command such as ps or top. However, you must calculate all memory usage by hand i.e. add Shared Memory + mapped file + total virtual memory size of the process + Resident Set Size + non-swapped physical memory used by process. So how do you find the memory used by a process or program under Linux? Use a tool called pmap. It reports the memory map of a process or processes.

pmap examples
To display process mappings, type
# ps aux | grep java | grep -v grep
root 32337 51.6 8.1 4845484 806488 pts/0 Sl 11:25 86:10 java -cp ../../GPhishing.jar:../../libs/* phishnet.srv.CPTUpdateDaemon
// pmap
# pmap 32337
32337: java -cp ../../GPhishing.jar:../../libs/* phishnet.srv.CPTUpdateDaemon
0000000000400000 4K r-x-- java
0000000000600000 4K r---- java
0000000000601000 4K rw--- java
000000000243d000 132K rw--- [ anon ]
000000075dc00000 27136K rw--- [ anon ]
000000075f680000 11776K ----- [ anon ]
...
00007fff5db0e000 132K rw--- [ stack ]
00007fff5dbfe000 8K r-x-- [ anon ]
ffffffffff600000 4K r-x-- [ anon ]
total 4845484K

The -x (Or --extended: Show the extended format.)option can be used to provide information about the memory allocation and mapping types per mapping. The amount of resident, non-shared anonymous, and locked memory is shown for each mapping:
# pmap -x 32337
32337: java -cp ../../GPhishing.jar:../../libs/* phishnet.srv.CPTUpdateDaemon
Address Kbytes RSS Dirty Mode Mapping
0000000000400000 4 4 0 r-x-- java
0000000000600000 4 4 4 r---- java
0000000000601000 4 4 4 rw--- java
000000000243d000 132 28 28 rw--- [ anon ]
...
---------------- ------- ------- -------
total kB 4851260 809964 792780


沒有留言:

張貼留言

[Git 常見問題] error: The following untracked working tree files would be overwritten by merge

  Source From  Here 方案1: // x -----删除忽略文件已经对 git 来说不识别的文件 // d -----删除未被添加到 git 的路径中的文件 // f -----强制运行 #   git clean -d -fx 方案2: 今天在服务器上  gi...