Linux进程占用内存分析之pmap

51 篇文章 0 订阅
查看进程的内存映像信息(report memory map of a process)
pmap
用法
pmap [options] PID [PID ...]
选项
Options:
 -x, --extended              show details //显示扩展格式
 -X                          show even more details
            WARNING: format changes according to /proc/PID/smaps
 -XX                         show everything the kernel provides
 -c, --read-rc               read the default rc
 -C, --read-rc-from=<file>   read the rc from file
 -n, --create-rc             create new default rc
 -N, --create-rc-to=<file>   create new rc to file
            NOTE: pid arguments are not allowed with -n, -N
 -d, --device                show the device format //显示设备格式
 -q, --quiet                 do not display header and footer //不显示头尾行
 -p, --show-path             show path in the mapping
 -A, --range=<low>[,<high>]  limit results to the given range

 -h, --help     display this help and exit
 -V, --version  output version information and exit //显示版本

扩展格式和设备格式域:
  Address:  start address of map  映像起始地址
  Kbytes:  size of map in kilobytes  映像大小(KB)
  RSS:  resident set size in kilobytes  驻留集大小(保留内存大小)(KB)
  Dirty:  dirty pages (both shared and private) in kilobytes  脏页大小(KB)
  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)  设备名

pmap -x 5002
5002:   /opt/jvm/java8/bin/java -Dorg.mortbay.util.URI.charset=UTF-8 -Xmx6008331k -Xms6008331k -XX:MaxPermSize=512m -Djava.library.path=/opt/app/../libswt/linux/x86_64/ ......
e.enc
Address           Kbytes     RSS   Dirty Mode  Mapping
0000000000400000       4       4       0 r-x-- java
0000000000600000       4       4       4 rw--- java
000000000120d000     132      24      24 rw---   [ anon ]
0000000651400000 6015488  573320  573320 rw---   [ anon ]
......
......
00007fffa449f000     132      44      44 rw---   [ stack ]
00007fffa45fe000       8       4       0 r-x--   [ anon ]
ffffffffff600000       4       0       0 r-x--   [ anon ]
---------------- ------- ------- ------- 
total kB         12052840  856168  806504

pmap -d pid
5002:   /opt/jvm/java8/bin/java -Dorg.mortbay.util.URI.charset=UTF-8 -Xmx6008331k -Xms6008331k -XX:MaxPermSize=512m -Djava.library.path=/opt/app/../libswt/linux/x86_64/ ......
Address           Kbytes Mode  Offset           Device    Mapping
0000000000400000       4 r-x-- 0000000000000000 0fd:00000 java
0000000000600000       4 rw--- 0000000000000000 0fd:00000 java
000000000120d000     132 rw--- 0000000000000000 000:00000   [ anon ]
......
......
00007fffa449f000     132 rw--- 0000000000000000 000:00000   [ stack ]
00007fffa45fe000       8 r-x-- 0000000000000000 000:00000   [ anon ]
ffffffffff600000       4 r-x-- 0000000000000000 000:00000   [ anon ]
mapped: 12014504K    writeable/private: 6589148K    shared: 38336K

最后一行的值
mapped:表示该进程映射的虚拟地址空间大小,也就是该进程预先分配的虚拟内存大小,即ps出的vsz
writeable/private:表示进程所占用的私有地址空间大小,也就是该进程实际使用的内存大小      
shared:表示进程和其他进程共享的内存大小

只显示最后一行:
pmap -d 5002 | tail -1
mapped: 12014504K    writeable/private: 6589148K    shared: 38336K

循环显示最后一行,试试监控进程内存占用情况:
#  while true; do pmap -d 5002 | tail -1; sleep 3; done

  • 0
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值