Introduction to pmap in Linux 1. Introduction to pmap (1) Name: pmap-report memory map of a process (view the memory image information of a process) (2) usage pmap [-x |-d] [-q] pids... pmap-V (3) Option meaning-x extended Show the extended format. display the extended format-d device Show the device format. display Device format-q quiet Do not display some header/footer lines. -V show version Displays version of program. display version (4) extended format and device format domain Address: start address of map image start Address Kbytes: size of map in Kilobytes image size RSS: resident set size in kilobytes resident set size Dirty: dirty pages (both shared and private) in kilobytes Dirty page size Mode: permissions on map image permission: 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. the image Supports files. [anon] indicates the allocated memory. [stack] indicates the program stack Offset: offset into the file Offset Device: devi. Ce name (major: minor) device name 2. Application Example [xxx @ xxx ~] # Pmap-d 21147 21147 :. /og1_service Address Kbytes Mode Offset Device Mapping 0000000000400000 360 r-x -- 0000000000000000 00:00002 og1_service running 4 rw --- 000000:00002 og1_service running 128 rw --- 000000000065b000 000:00000 [anon] 0000000011232000 523804 rw --- 0000000011232000 000:00000 [anon] 0000003304000000 12 r-x -- 0000000000000000 00:00002 libuuid. so.1.2 0000003304003000 2048 ----- 0000000000003000 002 libuuid. so.1.2 0000003304203000 4 rw --- 0000000000003000 libuuid. so.1.2 1000000376d000000 920 r-x -- 0000000000000000 00:00002 libstdc ++. so.6.0.8 000000376d0e6000 2044 ----- 00000000000e6000 00:00002 libstdc ++. so.6.0.8 000000376d2e5000 24 r ---- 00000000000e5000 00:00002 libstdc ++. so.6.0.8 000000376d2eb000 12 rw --- 00000000000eb000 00:00002 libstdc ++. so.6.0.8 11672 rw --- 0000000:00000 [anon] California 112 r-x -- 0000000000000000 00:00002 ld-2.5.so limit 4 r ---- 000000000001b000 00:00002 ld-2.5.so limit 4 rw --- 000000000001c000 00:00002 ld-2.5.so limit 1336 r-x -- 0000000000000000 003:00002 libc-2.5.so 00002048 ----- 000000000014e000 003:00002 libc-2.5.so 000016 r ---- 000000000014e000 003:00002 libc-2.5.so 00004 rw --- 0000000000152000 00:00002 libc-2.5.so 000020 rw --- 0000000:00000 [anon] 00008 r-x -- 0000000000000000 003: 2017003bc6002000 2048 ----- 0000000000002000 00:00002 libdl-2.5.so 0000003bc6202000 4 r ---- 0000000000002000 00:00002 libdl-2.5.so 00004 rw --- 0000000000003000 003:00002 libdl-2.5.so 0000520 r-x -- 0000000000000000 003:00002 libm-2.5.so 00002044 ----- 0000000000082000 00:00002 libm-2.5.so limit 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 00002044 ----- 0000000000016000 003:00002 libpthread-2.5.so 00004 r ---- 0000000000015000 003:00002 libpthread-2.5.so limit 16 rw --- 0000003bc6a17000 000:00000 [anon] 0000003bc6c00000 80 r-x -- 0000000000000000 00:00002 libz. so.1.2.3 2017003bc6c14000 2044 ----- 0000000000014000 00:00002 libz. so.1.2.3 10000003bc6e13000 4 rw --- 0000000000013000 00:00002 libz. so.1.2.3 0000003bc7800000 28 r-x -- 0000000000000000 003:00002 librt-2.5.so 00002048 ----- 0000000000007000 00:00002 librt-2.5.so 00004 r ---- 0000000000007000 00:00002 librt-2.5.so 00004 rw --- 0000000000008000 003:00002 librt-2.5.so 000052 r-x -- 0000000000000000 00:00002 libgcc_s-4.1.2-20080825.so.1 limit 2048 ----- 000000000000d000 00:00002 libgcc_s-4.1.2-20080825.so.1 00004 rw --- 000000000000d000 00:00002 libgcc_s-4.1.2-20080825.so.1 000020 rw --- 0000000:00000 [anon] 00004 rw --- 0000000:00000 [anon] limit 260 r-x -- 0000000000000000 00:00004 libevent. so %2b7b46ca7000 2048 ----- 0000000000041000 00:00004 libevent. so far 2b7b46ea7000 8 rw --- 0000000000041000 00:00004 libevent. so %2b7b46ea9000 4 rw --- %2b7b46ea9000 000:00000 [anon] %2b7b46eaa000 968 r-x -- 0000000000000000 00:00004 libprotobuf. so %2b7b46f9c000 2044 ----- %%000f2000 00:00004 libprotobuf. so %2b7b%b000 24 rw --- %%000f1000 00:00004 libprotobuf. so far 2b7b471a1000 504 r-x -- 0000000000000000 00:00004 liblog4cplus. so %2b7b4721f000 2048 ----- %%0007e000 00:00004 liblog4cplus. so far 2b7b4741f000 24 rw --- 000000000007e000 00:00004 liblog4cplus. so far 2b7b470000000 48 r-x -- 0000000000000000 00:00004 librabbitmq. so %2b7b47431000 2044 ----- %%%c000 00:00004 librabbitmq. so far 2b7b47630000 4 rw --- zookeeper b000 00:00004 librabbitmq. so far 1048 rw --- %2b7b47631000 000:00000 [anon] %7fffd6054000 84 rw --- %000:00000 [stack] %16 r-x -- %000:00000 [anon] %8192 ----- 0000000000000000 000:00000 [anon] mapped: 565476 K writeable/private: 525312 K shared: 0 K in the above heap, the value of the last line must know: mapped indicates the size of the virtual address space mapped by the process, that is, the virtual memory size pre-allocated by the process, that is, the ps vsz writeable/private indicates the size of the private address space occupied by the process, that is, the actual memory size shared by the process indicates the memory size shared by the process and other processes. 3. Other commands except pmap, in fact, there are other ways to statically view the memory usage of a process: (1) 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 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: 00000000 fffffeff CapEff: 00000000 fffffeff failed: large, small, 7 fffffff, ffffffff Mems_allowed: large memory, above there are two important parameters must know: VmSize: task virtual address space size VmRSS: physical memory size in use by the application