linux-命令-pmap相關
阿新 • • 發佈:2020-07-08
概述
用於檢視某個程序的 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 的記憶體。
參考
- https://mp.weixin.qq.com/s/K-6CPo1haIe65KZPdTHSrA