原文地址:33603https://www.cn blogs.com/gg jucheng/p/3348439.html
相关文章
1、linux的pmap命令— https://www.cn blogs.com/wangkang Luo1/archive/2012/06/04/2535121.html
2、Linux Pmap命令— -确定进程使用了多少https://OS.51cto.com/art/201311/415915.htm
3、Linux Pmap命令—确定进程使用了多少内存— https://Linux.cn/article-2217-1.html
4、使用top命令查看进程时,虚拟内存始终保持不变,但物理内存每5s增加12k或20k—https://BBS.csdn.net/topics/330185166? 位置编号=5
5、我的linux上的C程序为什么在虚拟内存(VSZ )持续增加一天之后又增加了好几倍? —-https://BBS.csdn.net/topics/330146607
名称:
pmap – report memory map of a process (查看进程的内存映像信息) ) ) )。
使用方法
pmap [ -x | -d ] [ -q ] pids .
pmap -V
选项的含义
– xextendedshowtheextendedformat .显示扩展格式
– d设备显示设备格式
– qquietdonotdisplaysomeheader/footer lines .不显示跟踪头
– vshowversiondisplaysversionofprogram .显示版本
扩展格式和设备格式字段:
地址:开始地址映射映像的起始地址
kbytes : size of map in kilobytes图像大小
RSS : residentsetsizeinkilobytes驻留集大小
dirty : dirty pages (bothsharedandprivate ) in kilobytes脏页的大小
模式: permissions on map映射权限: r=read,w=write,x=execute,s=shared,p=private(copyonwrite ) ) ) )。
mapping :文件备份地图,or ‘[anon]’ for allocated memory,or ‘[ stack ]’ for the program stack .图像支持文件,[ anon ]
Offset: offset into the file文件偏移
设备:设备名称(major : minor )设备名称
例如:
查看进程1的设备格式
[ root @ c44~] # pmap-d 113360 init [5] addresskbytesmodeoffsetdevicemapping 0093400088 r-x—- 000000000000000000000000000000360000000 LD-2.3.4.so 00094 a 000000000000000000000000000000000000000000000000000000 0000000160000000000000000000000000000000000000000000000000003300000000000000000000000000033300000000000000000000000000000000000000000000000000000000000000000000000000000000000000 8336000005 libc-2.3.4.so00a 790008 rw—- 000000012 b 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0a93000 32 rw— 0000000000a93000 000:00000 [ anon ]00d9d000 52 r-x– 0000000000000000 008:00005 libselinux.so.100daa000 4 rw— 000000000000d000 008:00005 libselinux.so.108048000 28 r-x– 0000000000000000 008:00005 init0804f000 4 rw— 0000000000007000 008:00005 init084e1000 132 rw— 00000000084e1000 000:00000 [ anon ]b7f5d000 8 rw— 00000000b7f5d000 000:00000 [ anon ]bffee000 72 rw— 00000000bffee000 000:00000 [ stack ]ffffe000 4 —– 0000000000000000 000:00000 [ anon ]mapped: 1700K writeable/private: 276K shared: 0K[root@C44 ~]#
最后一行的值
mapped 表示该进程映射的虚拟地址空间大小,也就是该进程预先分配的虚拟内存大小,即ps出的vsz
writeable/private 表示进程所占用的私有地址空间大小,也就是该进程实际使用的内存大小
shared 表示进程和其他进程共享的内存大小
查看进程1的设备格式,不显示头尾行
[root@C44 ~]# pmap -d -q 11: init [5] 00934000 88 r-x– 0000000000000000 008:00005 ld-2.3.4.so0094a000 4 r—- 0000000000015000 008:00005 ld-2.3.4.so0094b000 4 rw— 0000000000016000 008:00005 ld-2.3.4.so0094e000 1188 r-x– 0000000000000000 008:00005 libc-2.3.4.so00a77000 8 r—- 0000000000129000 008:00005 libc-2.3.4.so00a79000 8 rw— 000000000012b000 008:00005 libc-2.3.4.so00a7b000 8 rw— 0000000000a7b000 000:00000 [ anon ]00a85000 52 r-x– 0000000000000000 008:00005 libsepol.so.100a92000 4 rw— 000000000000c000 008:00005 libsepol.so.100a93000 32 rw— 0000000000a93000 000:00000 [ anon ]00d9d000 52 r-x– 0000000000000000 008:00005 libselinux.so.100daa000 4 rw— 000000000000d000 008:00005 libselinux.so.108048000 28 r-x– 0000000000000000 008:00005 init0804f000 4 rw— 0000000000007000 008:00005 init084e1000 132 rw— 00000000084e1000 000:00000 [ anon ]b7f5d000 8 rw— 00000000b7f5d000 000:00000 [ anon ]bffee000 72 rw— 00000000bffee000 000:00000 [ stack ]ffffe000 4 —– 0000000000000000 000:00000 [ anon ][root@C44 ~]#
查看进程1的扩展格式
[root@C44 ~]# pmap -x 11: init [5] Address Kbytes RSS Anon Locked Mode Mapping00934000 88 – – – r-x– ld-2.3.4.so0094a000 4 – – – r—- ld-2.3.4.so0094b000 4 – – – rw— ld-2.3.4.so0094e000 1188 – – – r-x– libc-2.3.4.so00a77000 8 – – – r—- libc-2.3.4.so00a79000 8 – – – rw— libc-2.3.4.so00a7b000 8 – – – rw— [ anon ]00a85000 52 – – – r-x– libsepol.so.100a92000 4 – – – rw— libsepol.so.100a93000 32 – – – rw— [ anon ]00d9d000 52 – – – r-x– libselinux.so.100daa000 4 – – – rw— libselinux.so.108048000 28 – – – r-x– init0804f000 4 – – – rw— init084e1000 132 – – – rw— [ anon ]b7f5d000 8 – – – rw— [ anon ]bffee000 72 – – – rw— [ stack ]ffffe000 4 – – – —– [ anon ]——– ——- ——- ——- ——-total kB 1700 – – -[root@C44 ~]#
循环显示进程3066的设备格式的最后1行,间隔2秒,
[root@C44 ~]# while true; do pmap -d 3066 | tail -1; sleep 2; donemapped: 5412K writeable/private: 2028K shared: 0Kmapped: 5412K writeable/private: 2028K shared: 0Kmapped: 5412K writeable/private: 2028K shared: 0Kmapped: 5412K writeable/private: 2028K shared: 0Kmapped: 5412K writeable/private: 2028K shared: 0Kmapped: 5412K writeable/private: 2028K shared: 0Kmapped: 5412K writeable/private: 2028K shared: 0Kmapped: 5412K writeable/private: 2028K shared: 0Kmapped: 5412K writeable/private: 2028K shared: 0Kmapped: 5412K writeable/private: 2028K shared: 0Kmapped: 5412K writeable/private: 2028K shared: 0Kmapped: 5412K writeable/private: 2028K shared: 0Kmapped: 5412K writeable/private: 2028K shared: 0K
转自 http://www.cnblogs.com/txw1958/archive/2012/07/26/linux-pmap.html
分类: Linux/Unix