≡ Menu

Check how much total memory is used by a process using pmap

On Linux, there are several commands that can be used to estimate the amount of memory that is used by a process, like top or ps. There is another command that can be used to find how much total memory is used by a process.

The command is called pmap.

The pmap command outputs the total memory used by a process (passed in the process ID) including a complete memory map of the process.

First, we need to locate the process ID of the process of which the memory map is desired.

[root@server ~]# ps aux | grep crond
root      9905  0.0  0.1   5500   724 pts/0    S+   12:56   0:00 grep crond
root     21647  0.0  0.2   7132  1176 ?        Ss   Sep19   0:00 crond
[root@server ~]#

Then I use the pmap command for the process ID 21647.

[root@server ~]# pmap 21647
21647:   crond
b7956000     48K r-x--  /lib/libnss_files-2.12.so
b7962000      4K r----  /lib/libnss_files-2.12.so
b7963000      4K rw---  /lib/libnss_files-2.12.so
b7969000      4K r----  /usr/lib/locale/locale-archive-rpm
b796a000   1144K r----  /usr/lib/locale/locale-archive-rpm
b7a88000   2048K r----  /usr/lib/locale/locale-archive-rpm
b7c88000      4K rw---    [ anon ]
b7c89000    316K r-x--  /lib/libfreebl3.so
b7cd8000      4K r----  /lib/libfreebl3.so
b7cd9000      4K rw---  /lib/libfreebl3.so
b7cda000     16K rw---    [ anon ]
b7cde000     28K r-x--  /lib/libcrypt-2.12.so
b7ce5000      4K r----  /lib/libcrypt-2.12.so
b7ce6000      4K rw---  /lib/libcrypt-2.12.so
b7ce7000    156K rw---    [ anon ]
b7d0e000   1600K r-x--  /lib/libc-2.12.so
b7e9e000      4K -----  /lib/libc-2.12.so
b7e9f000      8K r----  /lib/libc-2.12.so
b7ea1000      4K rw---  /lib/libc-2.12.so
b7ea2000     16K rw---    [ anon ]
b7ea6000     92K r-x--  /lib/libaudit.so.1.0.0
b7ebd000      4K r----  /lib/libaudit.so.1.0.0
b7ebe000     20K rw---  /lib/libaudit.so.1.0.0
b7ec3000     12K r-x--  /lib/libdl-2.12.so
b7ec6000      4K r----  /lib/libdl-2.12.so
b7ec7000      4K rw---  /lib/libdl-2.12.so
b7ec8000     48K r-x--  /lib/libpam.so.0.82.2
b7ed4000      4K r----  /lib/libpam.so.0.82.2
b7ed5000      4K rw---  /lib/libpam.so.0.82.2
b7ed6000    116K r-x--  /lib/libselinux.so.1
b7ef3000      4K r----  /lib/libselinux.so.1
b7ef4000      4K rw---  /lib/libselinux.so.1
b7efa000      4K rw---    [ anon ]
b7efb000    120K r-x--  /lib/ld-2.12.so
b7f19000      4K r----  /lib/ld-2.12.so
b7f1a000      4K rw---  /lib/ld-2.12.so
b7f1b000     56K r-x--  /usr/sbin/crond
b7f29000      4K r----  /usr/sbin/crond
b7f2a000      4K rw---  /usr/sbin/crond
b7f2b000    512K rw---    [ anon ]
b948a000    132K rw---    [ anon ]
bff20000    552K rw---    [ stack ]
 total     7128K
[root@server ~]#

So that is a complete memory memory map of the process crond. It shows that crond is using 7 MB of total memory which includes the swap space usage. Each entry in the memory map shows which module or file is being used and how much memory that module or file consumes when crond is running.

The command pmap can also be used to output an extended format using the -x option, available on most implementations.

{ 0 comments… add one }

Leave a Comment