现在的位置: 首页 > 综合 > 正文

Linux:pmap命令,查看进程占用的内存及使用地址空间(转)

2013年08月19日 ⁄ 综合 ⁄ 共 4155字 ⁄ 字号 评论关闭

http://www.cnblogs.com/tibetanmastiff/archive/2011/10/10/2205799.html

 

 

情景:

根据apache的工作方式,当我们要判断某个httpd进程使用内存的详细情况的时候,就用到了pmap命令:

 

例如:

1.查看pmap如何使用:

[root@CentOS5 ~]# man pmap

PMAP(1)                       Linux User’s Manual                      PMAP(1)

NAME
       pmap - report memory map of a process

SYNOPSIS
       pmap [ -x | -d ] [ -q ] pids...
       pmap -V

DESCRIPTION
       The pmap command reports the memory map of a process or processes.

GENERAL OPTIONS
       -x   extended       Show the extended format.
       -d   device         Show the device format.
       -q   quiet          Do not display some header/footer lines.
       -V   show version   Displays version of program.

SEE ALSO
       ps(1) pgrep(1)

STANDARDS
       No standards apply, but pmap looks an awful lot like a SunOS command.

AUTHOR
       Albert  Cahalan  <albert@users.sf.net> wrote pmap in 2002, and
is the cur-
       rent maintainer of the procps  collection.  Please  send  bug  reports  to
       <procps-feedback@lists.sf.net>.

Linux                          October 26, 2002                        PMAP(1)
(END)

2.参数说明:

       -x   extended       Show the extended format.
       -d   device         Show the device format.
       -q   quiet          Do not display some header/footer lines.
       -V   show version   Displays version of program.

 

3.举例:

查看系统进程:

[root@CentOS5 ~]#ps aux

USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME
COMMAND
root          0.0  0.0   2072   616 ?        Ss   May17   0:01
init [3]
(中间部分略)

daemon    9639  0.0  0.1  21164  8484 ?           13:11   0:00
/usr/local/apache2/bin/httpd

(下面部分略)

 

[root@CentOS5 ~]#pmap -d 9639
9639:   /usr/local/apache2/bin/httpd -k start
Address   Kbytes Mode  Offset           Device    Mapping
00110000      28 r-x-- 0000000000000000 008:00003 librt-2.5.so
00117000       4 r---- 0000000000006000 008:00003 librt-2.5.so
00118000       4 rw--- 0000000000007000 008:00003 librt-2.5.so
00119000    1276 r-x-- 0000000000000000 008:00003 libc-2.5.so
00258000       8 r---- 000000000013f000 008:00003 libc-2.5.so
0025a000       4 rw--- 0000000000141000 008:00003 libc-2.5.so
0025b000      12 rw--- 000000000025b000 000:00000   [ anon ]
0025e000      60 r-x-- 0000000000000000 008:00003 libexslt.so.0.8.12
0026d000       4 rw--- 000000000000e000 008:00003 libexslt.so.0.8.12
0026e000     268 r-x-- 0000000000000000 008:00003 libmysqlclient.so.16.0.0
002b1000     168 rw--- 0000000000042000 008:00003 libmysqlclient.so.16.0.0
002db000       4 rw--- 00000000002db000 000:00000   [ anon ]
002dc000     448 r-x-- 0000000000000000 008:00003 libfreetype.so.6.4.0
0034c000      16 rw--- 000000000006f000 008:00003 libfreetype.so.6.4.0
00350000      72 r-x-- 0000000000000000 008:00003 libz.so.1.2.3
00362000       4 rw--- 0000000000011000 008:00003 libz.so.1.2.3
00363000      60 r-x-- 0000000000000000 008:00003 libresolv-2.5.so
00372000       4 r---- 000000000000e000 008:00003 libresolv-2.5.so
00373000       4 rw--- 000000000000f000 008:00003 libresolv-2.5.so
00374000       8 rw--- 0000000000374000 000:00000   [ anon ]
00376000      76 r-x-- 0000000000000000 008:00003 libnsl-2.5.so
00389000       4 r---- 0000000000012000 008:00003 libnsl-2.5.so
0038a000       4 rw--- 0000000000013000 008:00003 libnsl-2.5.so
0038b000       8 rw--- 000000000038b000 000:00000   [ anon ]
0038d000     200 r-x-- 0000000000000000 008:00003 libcurl.so.3.0.0
003bf000       4 rw--- 0000000000031000 008:00003 libcurl.so.3.0.0
003c0000     192 r-x-- 0000000000000000 008:00003 libidn.so.11.5.19
003f0000       4 rw--- 000000000002f000 008:00003 libidn.so.11.5.19
003f1000     188 r-x-- 0000000000000000 008:00003 libxslt.so.1.1.15
00420000       4 rw--- 000000000002f000 008:00003 libxslt.so.1.1.15
00421000     588 r-x-- 0000000000000000 008:00003 libkrb5.so.3.3
004b4000      12 rw--- 0000000000092000 008:00003 libkrb5.so.3.3
004b7000       8 r-x-- 0000000000000000 008:00003 libcom_err.so.2.1
004b9000       4 rw--- 0000000000001000 008:00003 libcom_err.so.2.1
004ba000     148 r-x-- 0000000000000000 008:00003 libk5crypto.so.3.1
004df000       4 rw--- 0000000000025000 008:00003 libk5crypto.so.3.1
004e0000       8 r-x-- 0000000000000000 008:00003 libkeyutils-1.2.so
004e2000       4 rw--- 0000000000001000 008:00003 libkeyutils-1.2.so
004e3000      36 r-x-- 0000000000000000 008:00003 libnss_files-2.5.so
004ec000       4 r---- 0000000000008000 008:00003 libnss_files-2.5.so
004ed000       4 rw--- 0000000000009000 008:00003 libnss_files-2.5.so
004f4000    

抱歉!评论已关闭.