系统相关
首页 > 系统相关> > linux-命令-pmap相关

linux-命令-pmap相关

作者:互联网

概述

用于查看某个进程的 mmap 内存。

实例场景

例如我想知道某一个 进程(pid)分配的内存的情况,分配了那些内存地址,总的大小又有多大,就可以使用 pmap ,根绝具体的例子可以查看 Spring Boot “内存泄漏”?看看美团大牛是如何排查的

使用

使用我们直接

man pmap 

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.

EXTENDED AND DEVICE FORMAT FIELDS
       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: read, write, execute, shared, private (copy on write)
       Mapping:   file backing the map, or ’[ anon ]’ for allocated memory, or  ’[ stack ]’ for the program stack
       Offset:    offset into the file

例如我输入

pmap -x  22243 
00002ba744000000    1920    1844    1844 rw---    [ anon ]
00002ba7441e0000   63616       0       0 -----    [ anon ]
00002ba748000000    1800    1800    1800 rw---    [ anon ]
00002ba7481c2000   63736       0       0 -----    [ anon ]
00007ffdc7eee000      84      36      36 rw---    [ stack ]
00007ffdc7f06000       4       4       0 r-x--    [ anon ]
ffffffffff600000       4       0       0 r-x--    [ anon ]
----------------  ------  ------  ------
total kB         7981256 1246612 1232744

其中第二项就是实际占用内存大小,该例子中是占用了1.2G 的内存。

参考

标签:map,rw,命令,anon,内存,pmap,linux,stack
来源: https://www.cnblogs.com/Benjious/p/13265981.html