What is pmap ?

pmap displays the memory map of a process for the specified pid(s).

pmap -V
pmap from procps-ng 3.3.10

Syntax and Options

Usage:
 pmap [options] PID [PID ...]

Options:
 -x, --extended              show details
 -X                          show even more details
            WARNING: format changes according to /proc/PID/smaps
 -XX                         show everything the kernel provides
 -c, --read-rc               read the default rc
 -C, --read-rc-from=<file>   read the rc from file
 -n, --create-rc             create new default rc
 -N, --create-rc-to=<file>   create new rc to file
            NOTE: pid arguments are not allowed with -n, -N
 -d, --device                show the device format
 -q, --quiet                 do not display header and footer
 -p, --show-path             show path in the mapping
 -A, --range=<low>[,<high>]  limit results to the given range

 -h, --help     display this help and exit
 -V, --version  output version information and exit

Here are few pmap command examples:

View the memory map of a process

To view the memory map of a process, specify the PID of it. It displays the process name along with the memory map details as shown below.

pmap 5917
5917:   /usr/pgsql-9.4/bin/postgres -D /var/lib/pgsql/9.4/data
0000000000400000   5540K r-x-- postgres
0000000000b68000      4K r---- postgres
0000000000b69000     48K rw--- postgres
0000000000b75000    312K rw---   [ anon ]
00000000020c6000    276K rw---   [ anon ]
00007f9e051b6000 1145008K rw-s- zero (deleted)
...
00007f9e56501000     32K r---- libxml2.so.2.9.1
00007f9e56509000      8K rw--- libxml2.so.2.9.1
00007f9e5650b000      8K rw---   [ anon ]
00007f9e5650d000    132K r-x-- ld-2.17.so
00007f9e56701000     72K rw---   [ anon ]
00007f9e56727000     20K rw-s- PostgreSQL.1804289383
00007f9e5672c000      4K rw-s-   [ shmid=0x90000 ]
00007f9e5672d000      4K rw---   [ anon ]
00007f9e5672e000      4K r---- ld-2.17.so
00007f9e5672f000      4K rw--- ld-2.17.so
00007f9e56730000      4K rw---   [ anon ]
00007ffd07729000    144K rw---   [ stack ]
00007ffd077a5000      8K r-x--   [ anon ]
ffffffffff600000      4K r-x--   [ anon ]
 total          1337104K


View memory map of multiple processes

You can view multiple process memory map by specifying more than one pid in the command line.

$ pmap 3327 3353 3360

View extended memory map about a process

You can view memory map about a process in extended format using -x option as

pmap -x 22971
22971:   postgres: srmdcache dcache 127.0.0.1(54184) idle      
Address           Kbytes     RSS   Dirty Mode  Mapping
0000000000400000    5540    1932       0 r-x-- postgres
0000000000b68000       4       4       4 r---- postgres
0000000000b69000      48      48      48 rw--- postgres
0000000000b75000     312      52      52 rw---   [ anon ]
...
00007ffd077a5000       8       4       0 r-x--   [ anon ]
ffffffffff600000       4       0       0 r-x--   [ anon ]
---------------- ------- ------- -------
total kB         2484308    6168    3600

View even more extended memory map about a process

pmap -X 5917
5917:   /usr/pgsql-9.4/bin/postgres -D /var/lib/pgsql/9.4/data
         Address Perm   Offset Device    Inode    Size   Rss   Pss Referenced Anonymous Swap Locked Mapping
        00400000 r-xp 00000000  fd:00 17883608    5540   896    99        896         0    0      0 postgres
        00b68000 r--p 00568000  fd:00 17883608       4     4     0          0         4    0      0 postgres
        00b69000 rw-p 00569000  fd:00 17883608      48    32    10         12        32   16      0 postgres

View everything that kernel provides

pmap -XX 5917 | more
5917:   /usr/pgsql-9.4/bin/postgres -D /var/lib/pgsql/9.4/data
         Address Perm   Offset Device    Inode    Size   Rss   Pss Shared_Clean Shared_Dirty Private_Clean Private_D
irty Referenced Anonymous AnonHugePages Swap KernelPageSize MMUPageSize Locked                VmFlagsMapping
        00400000 r-xp 00000000  fd:00 17883608    5540   896   131          888            0             8          
   0        896         0             0    0              4           4      0    rd ex mr mw me dw  postgres
        00b68000 r--p 00568000  fd:00 17883608       4     4     0            0            4             0     

View mapped file path in the mapping

 pmap -p 5917 | more
5917:   /usr/pgsql-9.4/bin/postgres -D /var/lib/pgsql/9.4/data
0000000000400000   5540K r-x-- /usr/pgsql-9.4/bin/postgres
0000000000b68000      4K r---- /usr/pgsql-9.4/bin/postgres
0000000000b69000     48K rw--- /usr/pgsql-9.4/bin/postgres
...

View memory map of a process without header and footer

pmap -q 5917