The Linux pmap command displays the memory usage map of a process or multiple processes. Pmap reports information about the address space or memory usage map of a process.
Pmap is actually a Sun OS command and Linux supports only very limited number of features. But it is very helpful for finding the complete address space of a process. To check memory usage of process we need PID or unique process ID of running process, we can get PID from /proc or regular commands like top or ps.
Earlier we talked about process memory check using ps and top command, this tutorial I will teach how to use pmap command.
Usage syntax
Lets check the basic syntax of pmap command.
# pmap PID
or
# pmap [options] PID
In the output, it displays total address, kbytes, mode and mapping.
Options
-x extended Show the extended format. -d device Show the device format. -q quiet Do not display some header/footer lines. -V show version Displays version of program.
1) Memory usage map of single process
To check memory usage of a single process use map command followed by the PID number.
Let's check an pmap example:
# pmap 1013
1013: /usr/sbin/sshd 00110000 1480K r-x-- /usr/lib/libcrypto.so.1.0.0 00282000 80K rw--- /usr/lib/libcrypto.so.1.0.0 00296000 12K rw--- [ anon ] 00299000 36K r-x-- /lib/libkrb5support.so.0.1 002a2000 4K rw--- /lib/libkrb5support.so.0.1 00739000 4K rw--- /lib/libresolv-2.12.so 0073a000 8K rw--- [ anon ] 00825000 120K r-x-- /lib/ld-2.12.so 00843000 4K r---- /lib/ld-2.12.so 00844000 4K rw--- /lib/ld-2.12.so 0090d000 32K r-x-- /lib/libwrap.so.0.7.6 00915000 4K rw--- /lib/libwrap.so.0.7.6 00948000 484K r-x-- /usr/sbin/sshd 009c1000 8K rw--- /usr/sbin/sshd 009c3000 20K rw--- [ anon ] 009e0000 92K r-x-- /lib/libpthread-2.12.so 009f7000 4K r---- /lib/libpthread-2.12.so total 8232K
2) Memory usage map of multiple processes
We can check memory map of multiple processes by inserting multiple PIDs. For that add multiple PIDs with adding space.
# pmap 1013 1217 1118
3) Extended memory map about a process
To print extended memory information of a process use -x
option. Here Address, Kbyte, Dirty, RSS, mode and mapping contains information as below:
Extended and Device Format Fields
Address: start address of map Kbytes: size of map in kilobytes RSS: resident set size in kilobytes Dirty: dirty pages (both shared and private) in kilobytes Mode: permissions on map: read, write, execute, shared, private (copy on write) Mapping: file backing the map, or '[ anon ]' for allocated memory, or '[ stack ]' for the program stack Offset: offset into the file Device: device name (major:minor)
# pmap -x 1013 1013: /usr/sbin/sshd Address Kbytes RSS Dirty Mode Mapping 00110000 1480 92 0 r-x-- libcrypto.so.1.0.0 00282000 80 80 80 rw--- libcrypto.so.1.0.0 00296000 12 8 4 rw--- [ anon ] 00299000 36 0 0 r-x-- libkrb5support.so.0.1 002a2000 4 4 4 rw--- libkrb5support.so.0.1 002a3000 16 0 0 r-x-- libplc4.so 002a7000 4 4 4 rw--- libplc4.so 002ab000 88 4 0 r-x-- libaudit.so.1.0.0 002c1000 4 4 4 r---- libaudit.so.1.0.0 002c2000 4 4 4 rw--- libaudit.so.1.0.0 002c3000 216 4 0 r-x-- libgssapi_krb5.so.2.2 002f9000 4 4 4 rw--- libgssapi_krb5.so.2.2 002fa000 808 4 0 r-x-- libkrb5.so.3.3 003c4000 24 24 24 rw--- libkrb5.so.3.3 003ca000 152 4 0 r-x-- libk5crypto.so.3.1 003f0000 4 4 4 rw--- libk5crypto.so.3.1 003f1000 92 0 0 r-x-- libnssutil3.so 00408000 12 12 12 rw--- libnssutil3.so 0040b000 12 0 0 r-x-- libplds4.so 0040e000 4 4 4 rw--- libplds4.so -------- ------- ------- ------- ------- total kB 8232 - - -
Conclusion
In this tutorial we learn how to use pmap command to check memory information single and multiple processes. If you have any questions or feedback, feel free to leave a comment.