Skip to content

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
Output Columns: - Address: Start address of map. - Kbytes: Size in KB. - Mode: Permissions (r=read, w=write, x=execute, p=private, s=shared). - Mapping: Name of file/library or [ 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
- RSS: How much is actually in physical RAM. - Dirty: Modified pages (not yet written to disk).

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.

  1. Run pmap -x PID
  2. Wait.
  3. 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 sudo for others.
  • Shared Memory: Libraries like libc.so are visible in pmap. These are "shared" (RSS) across many processes, so adding up pmap totals for all processes will exceed physical RAM.