Report Memory Map of a Process in Linux

The pmap command can be used to obtain a memory map report for a process or list of processes. In my opinion, it is a great tool to explore memory leaks and any other memory related issues. If you simply invoke pmap with no options, it will list the usage with general available options, as shown below:

$ pmap
Usage: pmap [-x | -d] [-q] pid...
-x  show details
-d  show offset and device number
-q  quiet; less header/footer info
-V  show the version number
  • To view the memory map of  process or processes, simply type pmap followed by a pid—and for multiple processes separate the pids with a white space:
$ pmap 11443
11443:   bash
0000000000400000    712K r-x--  /bin/bash
00000000006b2000     40K rw---  /bin/bash
00000000006bc000     20K rw---    [ anon ]
00000000008bb000     32K rw---  /bin/bash
000000000a978000    264K rw---    [ anon ]
000000314cc00000    112K r-x--  /lib64/ld-2.5.so
000000314ce1b000      4K r----  /lib64/ld-2.5.so
000000314ce1c000      4K rw---  /lib64/ld-2.5.so
000000314d000000   1332K r-x--  /lib64/libc-2.5.so
000000314d14d000   2048K -----  /lib64/libc-2.5.so
000000314d34d000     16K r----  /lib64/libc-2.5.so
000000314d351000      4K rw---  /lib64/libc-2.5.so
000000314d352000     20K rw---    [ anon ]
000000314d400000      8K r-x--  /lib64/libdl-2.5.so
000000314d402000   2048K -----  /lib64/libdl-2.5.so
000000314d602000      4K r----  /lib64/libdl-2.5.so
000000314d603000      4K rw---  /lib64/libdl-2.5.so
000000314d800000     12K r-x--  /lib64/libtermcap.so.2.0.8
000000314d803000   2044K -----  /lib64/libtermcap.so.2.0.8
000000314da02000      4K rw---  /lib64/libtermcap.so.2.0.8
00002ba2a504e000      4K rw---    [ anon ]
00002ba2a5059000     12K rw---    [ anon ]
00002ba2a505c000  55112K r----  /usr/lib/locale/locale-archive
00002ba2a862e000    212K r--s-  /var/db/nscd/passwd
00002ba2a8663000     28K r--s-  /usr/lib64/gconv/gconv-modules.cache
00002ba2a866a000      4K rw---    [ anon ]
00007ffff140d000     84K rw---    [ stack ]
ffffffffff600000   8192K -----    [ anon ]
 total            72380K
  • Using option -x, you can print the memory map report in extended format:

$ pmap -x 11443
11443:   bash
Address           Kbytes     RSS    Anon  Locked Mode   Mapping
0000000000400000     712       -       -       - r-x--  bash
00000000006b2000      40       -       -       - rw---  bash
00000000006bc000      20       -       -       - rw---    [ anon ]
00000000008bb000      32       -       -       - rw---  bash
000000000a978000     264       -       -       - rw---    [ anon ]
000000314cc00000     112       -       -       - r-x--  ld-2.5.so
000000314ce1b000       4       -       -       - r----  ld-2.5.so
000000314ce1c000       4       -       -       - rw---  ld-2.5.so
000000314d000000    1332       -       -       - r-x--  libc-2.5.so
000000314d14d000    2048       -       -       - -----  libc-2.5.so
000000314d34d000      16       -       -       - r----  libc-2.5.so
000000314d351000       4       -       -       - rw---  libc-2.5.so
000000314d352000      20       -       -       - rw---    [ anon ]
000000314d400000       8       -       -       - r-x--  libdl-2.5.so
000000314d402000    2048       -       -       - -----  libdl-2.5.so
000000314d602000       4       -       -       - r----  libdl-2.5.so
000000314d603000       4       -       -       - rw---  libdl-2.5.so
000000314d800000      12       -       -       - r-x--  libtermcap.so.2.0.8
000000314d803000    2044       -       -       - -----  libtermcap.so.2.0.8
000000314da02000       4       -       -       - rw---  libtermcap.so.2.0.8
00002ba2a504e000       4       -       -       - rw---    [ anon ]
00002ba2a5059000      12       -       -       - rw---    [ anon ]
00002ba2a505c000   55112       -       -       - r----  locale-archive
00002ba2a862e000     212       -       -       - r--s-  passwd
00002ba2a8663000      28       -       -       - r--s-  gconv-modules.cache
00002ba2a866a000       4       -       -       - rw---    [ anon ]
00007ffff140d000      84       -       -       - rw---    [ stack ]
ffffffffff600000    8192       -       -       - -----    [ anon ]
----------------  ------  ------  ------  ------
total kB           72380       -       -       -

  • Using option -d, you can print the memory map report with offset and device number:

$ pmap -d 11443
11443:   bash
Address           Kbytes Mode  Offset           Device    Mapping
0000000000400000     712 r-x-- 0000000000000000 0fd:00000 bash
00000000006b2000      40 rw--- 00000000000b2000 0fd:00000 bash
00000000006bc000      20 rw--- 00000000006bc000 000:00000   [ anon ]
00000000008bb000      32 rw--- 00000000000bb000 0fd:00000 bash
000000000a978000     264 rw--- 000000000a978000 000:00000   [ anon ]
000000314cc00000     112 r-x-- 0000000000000000 0fd:00000 ld-2.5.so
000000314ce1b000       4 r---- 000000000001b000 0fd:00000 ld-2.5.so
000000314ce1c000       4 rw--- 000000000001c000 0fd:00000 ld-2.5.so
000000314d000000    1332 r-x-- 0000000000000000 0fd:00000 libc-2.5.so
000000314d14d000    2048 ----- 000000000014d000 0fd:00000 libc-2.5.so
000000314d34d000      16 r---- 000000000014d000 0fd:00000 libc-2.5.so
000000314d351000       4 rw--- 0000000000151000 0fd:00000 libc-2.5.so
000000314d352000      20 rw--- 000000314d352000 000:00000   [ anon ]
000000314d400000       8 r-x-- 0000000000000000 0fd:00000 libdl-2.5.so
000000314d402000    2048 ----- 0000000000002000 0fd:00000 libdl-2.5.so
000000314d602000       4 r---- 0000000000002000 0fd:00000 libdl-2.5.so
000000314d603000       4 rw--- 0000000000003000 0fd:00000 libdl-2.5.so
000000314d800000      12 r-x-- 0000000000000000 0fd:00000 libtermcap.so.2.0.8
000000314d803000    2044 ----- 0000000000003000 0fd:00000 libtermcap.so.2.0.8
000000314da02000       4 rw--- 0000000000002000 0fd:00000 libtermcap.so.2.0.8
00002ba2a504e000       4 rw--- 00002ba2a504e000 000:00000   [ anon ]
00002ba2a5059000      12 rw--- 00002ba2a5059000 000:00000   [ anon ]
00002ba2a505c000   55112 r---- 0000000000000000 0fd:00001 locale-archive
00002ba2a862e000     212 r--s- 0000000000000000 0fd:00002 passwd
00002ba2a8663000      28 r--s- 0000000000000000 0fd:00001 gconv-modules.cache
00002ba2a866a000       4 rw--- 00002ba2a866a000 000:00000   [ anon ]
00007ffff140d000      84 rw--- 00007ffffffea000 000:00000   [ stack ]
ffffffffff600000    8192 ----- 0000000000000000 000:00000   [ anon ]
mapped: 72380K    writeable/private: 496K    shared: 240K

Basic description of summary columns in the footer, line #32:

  • mapped:  Amount of memory mapped to files
  • writeable/private: Amount of private address space
  • shared: Amount of Address Space that is being shared with others by this process

Leave a Comment

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload the CAPTCHA.