pmap Command Cheat Sheet
pmap reports the memory map of a process or processes. It allows you to see exactly how memory is being used (libraries, stack, heap).
Synopsis
pmap [options] PID
Basic Usage
Show Memory Map
pmap 1234
[ heap ] / [ stack ].
Example Output
000055d4a6b00000 44K r-x-- /usr/bin/cat
000055d4a840d000 132K rw--- [ heap ]
...
00007ffcc9d3d000 132K rw--- [ stack ]
total 123456K
Detailed Analysis
Extended Format (-x)
Shows RSS (Resident Set Size) and Dirty pages.
pmap -x 1234
Very Detailed Format (-XX)
Shows everything kernel knows about the mapping.
pmap -XX 1234
Identifying Leaks
If [ heap ] or [ anon ] sections are growing continuously over time, you likely have a memory leak.
- Run
pmap -x PID - Wait.
- Run it again and compare "total Rs" and "[ heap ]" sizes.
Device Format (-d)
Shows device offsets (major:minor).
pmap -d 1234
Notes
- Permissions: You can only map processes you own. Use
sudofor others. - Shared Memory: Libraries like
libc.soare visible inpmap. These are "shared" (RSS) across many processes, so adding uppmaptotals for all processes will exceed physical RAM.