一、pmap简介
(1)名称:
pmap - report memory map of a process(查看进程的内存映像信息)
(2)用法
pmap [ -x | -d ] [ -q ] pids...
pmap -V
(3)选项含义
-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. 显示版本
(4)扩展格式和设备格式域
Address: start address of map 映像起始地址
Kbytes: size of map in kilobytes 映像大小
RSS: resident set size in kilobytes 驻留集大小
Dirty: dirty pages (both shared and private) in kilobytes 脏页大小
Mode: permissions on map 映像权限: r=read, w=write, x=execute, s=shared, p=private (copy on write)
Mapping: file backing the map , or '[ anon ]' for allocated memory, or '[ stack ]' for the program stack. 映像支持文件,[anon]为已分配内存 [stack]为程序堆栈
Offset: offset into the file 文件偏移
Device: device name (major:minor) 设备名
二、应用举例
[xxx@xxx ~]# pmap -d 21147
21147: ./ogassistservice
Address Kbytes Mode Offset Device Mapping
0000000000400000 360 r-x-- 0000000000000000 003:00002 ogassistservice
000000000065a000 4 rw--- 000000000005a000 003:00002 ogassistservice
000000000065b000 128 rw--- 000000000065b000 000:00000 [ anon ]
0000000011232000 523804 rw--- 0000000011232000 000:00000 [ anon ]
0000003304000000 12 r-x-- 0000000000000000 003:00002 libuuid.so.1.2
0000003304003000 2048 ----- 0000000000003000 003:00002 libuuid.so.1.2
0000003304203000 4 rw--- 0000000000003000 003:00002 libuuid.so.1.2
000000376d000000 920 r-x-- 0000000000000000 003:00002 libstdc++.so.6.0.8
000000376d0e6000 2044 ----- 00000000000e6000 003:00002 libstdc++.so.6.0.8
000000376d2e5000 24 r---- 00000000000e5000 003:00002 libstdc++.so.6.0.8
000000376d2eb000 12 rw--- 00000000000eb000 003:00002 libstdc++.so.6.0.8
000000376d2ee000 72 rw--- 000000376d2ee000 000:00000 [ anon ]
0000003bc5800000 112 r-x-- 0000000000000000 003:00002 ld-2.5.so
0000003bc5a1b000 4 r---- 000000000001b000 003:00002 ld-2.5.so
0000003bc5a1c000 4 rw--- 000000000001c000 003:00002 ld-2.5.so
0000003bc5c00000 1336 r-x-- 0000000000000000 003:00002 libc-2.5.so
0000003bc5d4e000 2048 ----- 000000000014e000 003:00002 libc-2.5.so
0000003bc5f4e000 16 r---- 000000000014e000 003:00002 libc-2.5.so
0000003bc5f52000 4 rw--- 0000000000152000 003:00002 libc-2.5.so
0000003bc5f53000 20 rw--- 0000003bc5f53000 000:00000 [ anon ]
0000003bc6000000 8 r-x-- 0000000000000000 003:00002 libdl-2.5.so
0000003bc6002000 2048 ----- 0000000000002000 003:00002 libdl-2.5.so
0000003bc6202000 4 r---- 0000000000002000 003:00002 libdl-2.5.so
0000003bc6203000 4 rw--- 0000000000003000 003:00002 libdl-2.5.so
0000003bc6400000 520 r-x-- 0000000000000000 003:00002 libm-2.5.so
0000003bc6482000 2044 ----- 0000000000082000 003:00002 libm-2.5.so
0000003bc6681000 4 r---- 0000000000081000 003:00002 libm-2.5.so
0000003bc6682000 4 rw--- 0000000000082000 003:00002 libm-2.5.so
0000003bc6800000 88 r-x-- 0000000000000000 003:00002 libpthread-2.5.so
0000003bc6816000 2044 ----- 0000000000016000 003:00002 libpthread-2.5.so
0000003bc6a15000 4 r---- 0000000000015000 003:00002 libpthread-2.5.so
0000003bc6a16000 4 rw--- 0000000000016000 003:00002 libpthread-2.5.so
0000003bc6a17000 16 rw--- 0000003bc6a17000 000:00000 [ anon ]
0000003bc6c00000 80 r-x-- 0000000000000000 003:00002 libz.so.1.2.3
0000003bc6c14000 2044 ----- 0000000000014000 003:00002 libz.so.1.2.3
0000003bc6e13000 4 rw--- 0000000000013000 003:00002 libz.so.1.2.3
0000003bc7800000 28 r-x-- 0000000000000000 003:00002 librt-2.5.so
0000003bc7807000 2048 ----- 0000000000007000 003:00002 librt-2.5.so
0000003bc7a07000 4 r---- 0000000000007000 003:00002 librt-2.5.so
0000003bc7a08000 4 rw--- 0000000000008000 003:00002 librt-2.5.so
0000003bc7c00000 52 r-x-- 0000000000000000 003:00002 libgcc_s-4.1.2-20080825.so.1
0000003bc7c0d000 2048 ----- 000000000000d000 003:00002 libgcc_s-4.1.2-20080825.so.1
0000003bc7e0d000 4 rw--- 000000000000d000 003:00002 libgcc_s-4.1.2-20080825.so.1
00002b7b46c54000 20 rw--- 00002b7b46c54000 000:00000 [ anon ]
00002b7b46c5a000 4 rw--- 00002b7b46c5a000 000:00000 [ anon ]
00002b7b46c66000 260 r-x-- 0000000000000000 003:00004 libevent.so
00002b7b46ca7000 2048 ----- 0000000000041000 003:00004 libevent.so
00002b7b46ea7000 8 rw--- 0000000000041000 003:00004 libevent.so
00002b7b46ea9000 4 rw--- 00002b7b46ea9000 000:00000 [ anon ]
00002b7b46eaa000 968 r-x-- 0000000000000000 003:00004 libprotobuf.so
00002b7b46f9c000 2044 ----- 00000000000f2000 003:00004 libprotobuf.so
00002b7b4719b000 24 rw--- 00000000000f1000 003:00004 libprotobuf.so
00002b7b471a1000 504 r-x-- 0000000000000000 003:00004 liblog4cplus.so
00002b7b4721f000 2048 ----- 000000000007e000 003:00004 liblog4cplus.so
00002b7b4741f000 24 rw--- 000000000007e000 003:00004 liblog4cplus.so
00002b7b47425000 48 r-x-- 0000000000000000 003:00004 librabbitmq.so
00002b7b47431000 2044 ----- 000000000000c000 003:00004 librabbitmq.so
00002b7b47630000 4 rw--- 000000000000b000 003:00004 librabbitmq.so
00002b7b47631000 1048 rw--- 00002b7b47631000 000:00000 [ anon ]
00007fffd6054000 84 rw--- 00007ffffffe9000 000:00000 [ stack ]
00007fffd61ac000 16 r-x-- 00007fffd61ac000 000:00000 [ anon ]
ffffffffff600000 8192 ----- 0000000000000000 000:00000 [ anon ]
mapped: 565476K writeable/private: 525312K shared: 0K
上面这一堆中,最后一行的值必须知道:
mapped 表示该进程映射的虚拟地址空间大小,也就是该进程预先分配的虚拟内存大小,即ps出的vsz
writeable/private 表示进程所占用的私有地址空间大小,也就是该进程实际使用的内存大小
shared 表示进程和其他进程共享的内存大小
三、其它命令
除了pmap外,其实还有别的手段可以用于静态查看某个进程的内存使用情况:
(1)ps
ps -aux|grep process_name
(2)cat /proc/process_id/status
Name: xxx
State: S (sleeping)
SleepAVG: 98%
Tgid: 21147
Pid: 21147
PPid: 18228
TracerPid: 0
Uid: 0 0 0 0
Gid: 0 0 0 0
FDSize: 131072
Groups: 0 1 2 6 10
VmPeak: 557288 kB
VmSize: 557288 kB
VmLck: 0 kB
VmHWM: 527480 kB
VmRSS: 527480 kB
VmData: 525132 kB
VmStk: 88 kB
VmExe: 360 kB
VmLib: 4936 kB
VmPTE: 1140 kB
StaBrk: 11232000 kB
Brk: 311b9000 kB
StaStk: 7fffd60678c0 kB
Threads: 1
SigQ: 0/16383
SigPnd: 0000000000000000
ShdPnd: 0000000000000000
SigBlk: 0000000000000000
SigIgn: 0000000000001000
SigCgt: 0000000180000000
CapInh: 0000000000000000
CapPrm: 00000000fffffeff
CapEff: 00000000fffffeff
Cpus_allowed: 00000000,00000000,00000000,00000000,00000000,00000000,7fffffff,ffffffff
Mems_allowed: 00000000,00000001
上面这一堆中有两个重要参数必须知道:
VmSize:任务虚拟地址空间大小
VmRSS:应用程序正在使用的物理内存大小
阅读(5549) | 评论(2) | 转发(2) |