Linux Tutorials - Herong's Tutorial Examples - v5.45, by Herong Yang
pmap - Process Memory Map
This section provides a tutorial on how to install 'smem' and use it to report memory usage of each running process.
What Is "pmap"? - "pmap" is a Linux command that reports the virtual memory map of a given process. Here are some examples of "pmap" command output:
1. Report virtual memory map for process ID 1998.
herong$ sudo pmap 1998 1998: /usr/libexec/mysqld --basedir=/usr 0000561c0ddea000 60468K r-x-- mysqld 0000561c118f7000 1492K r---- mysqld 0000561c11a6c000 3612K rw--- mysqld 0000561c11df3000 5300K rw--- [ anon ] 0000561c1403c000 79032K rw--- [ anon ] 00007ff90ac25000 24K r-x-- libevent_openssl-2.1.so.6.0.2 00007ff90ac2b000 2044K ----- libevent_openssl-2.1.so.6.0.2 00007ff90ae2a000 4K r---- libevent_openssl-2.1.so.6.0.2 00007ff90ae2b000 4K rw--- [ anon ] ... total 3439672K
The output shows that:
2. Report virtual memory map in the extended format, which provides 2 extra output fields and field headers.
herong$ sudo pmap -x 1998 1998: /usr/libexec/mysqld --basedir=/usr Address Kbytes RSS Dirty Mode Mapping 0000561c0ddea000 60468 13552 0 r-x-- mysqld 0000561c118f7000 1492 672 672 r---- mysqld 0000561c11a6c000 3612 252 224 rw--- mysqld 0000561c11df3000 5300 1524 1524 rw--- [ anon ] 0000561c1403c000 79032 45400 45400 rw--- [ anon ] 00007ff838000000 37204 27912 27912 rw--- [ anon ] 00007ff83a455000 28332 0 0 ----- [ anon ] 00007ff90b6d5000 4 4 4 r---- ld-2.28.so 00007ff90b6d6000 8 8 8 rw--- ld-2.28.so 00007ffcf9398000 132 8 8 rw--- [ stack ] ... total kB 3439672 655928 638844
Compare "pmap", "ps" and "smem" Reports - Here are the outputs of "pmap", "ps" and "smem" commands on process id 1998 (MySQL Server).
herong$ sudo pmap -x 1998 1998: /usr/libexec/mysqld --basedir=/usr ... Address Kbytes RSS Dirty Mode Mapping total kB 3439672 655928 638844 herong$ sudo smem -P mysqld PID User Command Swap USS PSS RSS 1998 mysql /usr/libexec/mysqld 388652 652612 653036 655928 herong$ ps -o pid,euser,%mem,rss,drs,trs,sz,vsz,comm -p 1998 PID EUSER %MEM RSS DRS TRS SZ VSZ COMMAND 1998 mysql 4.1 645924 3439668 0 859917 3439668 mysqld
Those outputs show that:
Table of Contents
Cockpit - Web Portal for Administrator
Layers of Memory and Access Speed
List CPU Caches and Their Sizes
Virtual Memory vs. Physical Memory
Buffer Memory and Cache Memory
Verify Cache Memory with "cp" Command
Virtual Memory Mapping and Page Table
"ps -o rss,drs,trs,vsz,sz" - Process Status Options
smem - Process Memory Usage Report
/proc/{id}/maps - Process Memory Map
/proc/{id}/smaps - Process Memory Map Details
SELinux - Security-Enhanced Linux
SSH Protocol and ssh/scp Commands
Software Package Manager on CentOS - DNF and YUM
vsftpd - Very Secure FTP Daemon