Pages

Saturday, September 15, 2012

Resource Management : Pmap


pmap command can be used to understand virtual memory mapping of an UNIX process, memory usage, and attributes of memory area etc.

View the memory map of a process
[root@vx111a test]# pmap 4226
4226:   /bin/bash ./top.sh
006db000    108K r-x--  /lib/ld-2.5.so
006f6000      4K r-x--  /lib/ld-2.5.so
006f7000      4K rwx--  /lib/ld-2.5.so
006fa000   1356K r-x--  /lib/libc-2.5.so
0084d000      8K r-x--  /lib/libc-2.5.so
0084f000      4K rwx--  /lib/libc-2.5.so
00850000     12K rwx--    [ anon ]
00880000     12K r-x--  /lib/libdl-2.5.so
00883000      4K r-x--  /lib/libdl-2.5.so
00884000      4K rwx--  /lib/libdl-2.5.so
008b7000     12K r-x--  /lib/libtermcap.so.2.0.8
008ba000      4K rwx--  /lib/libtermcap.so.2.0.8
00faf000      4K r-x--  &an>
b7f61000      8K rw---    [ anon ]
b7f6c000     28K r--s-  /usr/lib/gconv/gconv-modules.cache
bfe07000     84K rw---    [ stack ] 0971a000    132K rw---    [ anon ]
b7d61000   2048K r----  /usr/lib/locale/locale-archive
b7f61000      8K rw---    [ anon ]
b7f6c000     28K r--s-  /usr/lib/gconv/gconv-modules.cache
bfe07000     84K rw---    [ stack ]
 total     4572K

When we see the output of this command, it will give details as follows
1.First column will show memory location
2.second column will show RAM use of each file opened by this process
3.Third column will show rw permission.
4.Last one will show what are the files opened by this process
5.And last line of this output will show total size used, here it is 4572K

Show Extended Format

[root@vx111a test]# pmap -x 4226
4226:   /bin/bash ./top.sh
Address   Kbytes     RSS   Dirty Mode   Mapping
006db000     108      84       0 r-x--  ld-2.5.so
006f6000       4       4       4 r-x--  ld-2.5.so
006f7000       4       4       4 rwx--  ld-2.5.so
006fa000    1356     404       0 r-x--  libc-2.5.so
0084d000       8       8       4 r-x--  libc-2.5.so
0084f000       4       4       4 rwx--  libc-2.5.so
00850000      12      12      12 rwx--    [ anon ]
00880000      12       8       0 r-x--  libdl-2.5.so
00883000       4       4       4 r-x--  libdl-2.5.so
00884000       4       4       4 rwx--  libdl-2.5.so
008b7000      12       8       0 r-x--  libtermcap.so.2.0.8
008ba000       4       4       4 rwx--  libtero:p>
0971a000   &nbsbsp;      4       4       0 r-x--    [ anon ]
08047000     696    yle="color: #002060; font-family: "Verdana","sans-serif"; font-size: 9.0pt; line-height: 115%; mso-bidi-font-size: 11.0pt;">0971a000    132K rw---    [ anon ]
b7d61000   2048K r----  /usr/lib/locale/locale-archive
b7f61000      8K rw---    [ anon ]
b7fp; 132      20      20 rw---    [ anon ]
b7d61000    2048      44       0 r----  locale-archive
b7f61000       8       8       8 rw---    [ anon ]
b7f6c000      28      24       0 r--s-  gconv-modules.cache
bfe07000      84      16      16 rw---    [ stack ]
.
.
.
------- ------- ------- ------- -------
total kB    641180   99088   89424

Total virtual memory mapped by this process is 641180 KB.