/proc/{id}/maps - Process Memory Map

This section describes the pseudo file '/proc/{id}/maps' that represents virtual memory map of a given process.

What Is /proc/{id}/maps? - /proc/{id}/maps is a pseudo file that contains the memory map of the process of the given id.

Here is the memory map for process ID 1998 retrieved from the /proc/1998/maps pseudo file.

herong$ sudo cat /proc/1998/maps 

561c0ddea000-561c118f7000 r-xp 00000000 fd:00 36252107   /usr/libexec/mysqld
561c118f7000-561c11a6c000 r--p 03b0c000 fd:00 36252107   /usr/libexec/mysqld
561c11a6c000-561c11df3000 rw-p 03c81000 fd:00 36252107   /usr/libexec/mysqld
561c11df3000-561c12320000 rw-p 00000000 00:00 0 
561c1403c000-561c18d6a000 rw-p 00000000 00:00 0          [heap]
7ff838000000-7ff83a455000 rw-p 00000000 00:00 0 
7ff83a455000-7ff83c000000 ---p 00000000 00:00 0 
...
7ff90b6d5000-7ff90b6d6000 r--p 0002c000 fd:00 46923995   /usr/lib64/ld-2.28.so
7ff90b6d6000-7ff90b6d8000 rw-p 0002d000 fd:00 46923995   /usr/lib64/ld-2.28.so
7ffcf9398000-7ffcf93b9000 rw-p 00000000 00:00 0          [stack]
7ffcf93da000-7ffcf93dd000 r--p 00000000 00:00 0          [vvar]
7ffcf93dd000-7ffcf93df000 r-xp 00000000 00:00 0          [vdso]
ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0  [vsyscall]

The output fields in each line are described below:

start-end perm offset major:minor inode image

where: 
  start - The starting address of the mapped virtual memory area. 
  end   - The ending address of the mapped virtual memory area. 
  perm  - A 4-bit mask with the first three bits representing process 
          r (read), w (write) and x (execute) permissions for the 
          area. The last bit is process ownership of the area: 
          p (private) or s (shared). 
  offset - The offset in the file where is area is mapped to.
  major - The major number of the device holding the mapped-to file. 
  minor - The minor number of the device holding the mapped-to file. 
  inode - The inode number of the mapped-to file.
  image - The name of the mapped-to file.

Compare "/proc/{id}/maps" and "pmap" Reports - Looking at their outputs, the "pmap" command seems to be using the "/proc/{id}/maps" pseudo file to generate report. Let's confirm this with a simple process, "sleep".

herong$ sleep 600000000 &
649848

herong$ sudo pmap -x 649848
649848:   sleep 600000000
Address           Kbytes     RSS   Dirty Mode  Mapping
000056392fc85000      28      28       0 r-x-- sleep
000056392fe8c000       4       4       4 r---- sleep
000056392fe8d000       4       4       4 rw--- sleep
0000563931dd7000     132      24      24 rw---   [ anon ]
00007f47dc913000    2740     192       0 r---- LC_COLLATE
00007f47dcbc0000    1776    1216       0 r-x-- libc-2.28.so
00007f47dcd7c000    2044       0       0 ----- libc-2.28.so
00007f47dcf7b000      16      16      16 r---- libc-2.28.so
00007f47dcf7f000       8       8       8 rw--- libc-2.28.so
00007f47dcf81000      16      12      12 rw---   [ anon ]
00007f47dcf85000     176     172       0 r-x-- ld-2.28.so
00007f47dd149000     332     128       0 r---- LC_CTYPE
00007f47dd19c000       4       4       0 r---- LC_NUMERIC
00007f47dd19d000       4       4       0 r---- LC_TIME
00007f47dd19e000       4       4       0 r---- LC_MONETARY
00007f47dd19f000       4       4       0 r---- SYS_LC_MESSAGES
00007f47dd1a0000       4       4       0 r---- LC_PAPER
00007f47dd1a1000       8       4       4 rw---   [ anon ]
00007f47dd1a3000       4       4       0 r---- LC_NAME
00007f47dd1a4000       4       4       0 r---- LC_ADDRESS
00007f47dd1a5000       4       4       0 r---- LC_TELEPHONE
00007f47dd1a6000       4       4       0 r---- LC_MEASUREMENT
00007f47dd1a7000      28      28       0 r--s- gconv-modules.cache
00007f47dd1ae000       4       4       0 r---- LC_IDENTIFICATION
00007f47dd1af000       8       8       8 rw---   [ anon ]
00007f47dd1b1000       4       4       4 r---- ld-2.28.so
00007f47dd1b2000       8       8       8 rw--- ld-2.28.so
00007fff6435e000     132      12      12 rw---   [ stack ]
00007fff6438d000      16       0       0 r----   [ anon ]
00007fff64391000       8       4       0 r-x--   [ anon ]
ffffffffff600000       4       0       0 r-x--   [ anon ]
---------------- ------- ------- ------- 
total kB            7532    1912     104

herong$ sudo cat /proc/649848/maps 
56392fc85000-56392fc8c000 r-xp 00000000 fd:00 63570     /usr/bin/sleep
56392fe8c000-56392fe8d000 r--p 00007000 fd:00 63570     /usr/bin/sleep
56392fe8d000-56392fe8e000 rw-p 00008000 fd:00 63570     /usr/bin/sleep
563931dd7000-563931df8000 rw-p 00000000 00:00 0         [heap]
7f47dc913000-7f47dcbc0000 r--p 00000000 fd:00 33630723  /usr/lib/locale/zh_CN.utf8/LC_COLLATE
7f47dcbc0000-7f47dcd7c000 r-xp 00000000 fd:00 75501124  /usr/lib64/libc-2.28.so
7f47dcd7c000-7f47dcf7b000 ---p 001bc000 fd:00 75501124  /usr/lib64/libc-2.28.so
7f47dcf7b000-7f47dcf7f000 r--p 001bb000 fd:00 75501124  /usr/lib64/libc-2.28.so
7f47dcf7f000-7f47dcf81000 rw-p 001bf000 fd:00 75501124  /usr/lib64/libc-2.28.so
7f47dcf81000-7f47dcf85000 rw-p 00000000 00:00 0 
7f47dcf85000-7f47dcfb1000 r-xp 00000000 fd:00 76867831  /usr/lib64/ld-2.28.so
7f47dd149000-7f47dd19c000 r--p 00000000 fd:00 33557602  /usr/lib/locale/zh_CN.utf8/LC_CTYPE
7f47dd19c000-7f47dd19d000 r--p 00000000 fd:00 33630731  /usr/lib/locale/zh_CN.utf8/LC_NUMERIC
7f47dd19d000-7f47dd19e000 r--p 00000000 fd:00 33630727  /usr/lib/locale/zh_CN.utf8/LC_TIME
7f47dd19e000-7f47dd19f000 r--p 00000000 fd:00 33630725  /usr/lib/locale/zh_CN.utf8/LC_MONETARY
7f47dd19f000-7f47dd1a0000 r--p 00000000 fd:00 42190048  /usr/lib/locale/zh_CN.utf8/LC_MESSA...
7f47dd1a0000-7f47dd1a1000 r--p 00000000 fd:00 33630732  /usr/lib/locale/zh_CN.utf8/LC_PAPER
7f47dd1a1000-7f47dd1a3000 rw-p 00000000 00:00 0 
7f47dd1a3000-7f47dd1a4000 r--p 00000000 fd:00 33630730  /usr/lib/locale/zh_CN.utf8/LC_NAME
7f47dd1a4000-7f47dd1a5000 r--p 00000000 fd:00 33630722  /usr/lib/locale/zh_CN.utf8/LC_ADDRESS
7f47dd1a5000-7f47dd1a6000 r--p 00000000 fd:00 33630726  /usr/lib/locale/zh_CN.utf8/LC_TELEPHONE
7f47dd1a6000-7f47dd1a7000 r--p 00000000 fd:00 33630729  /usr/lib/locale/zh_CN.utf8/LC_MEASU...
7f47dd1a7000-7f47dd1ae000 r--s 00000000 fd:00 109056718 /usr/lib64/gconv/gconv-modules.cache
7f47dd1ae000-7f47dd1af000 r--p 00000000 fd:00 33630724  /usr/lib/locale/zh_CN.utf8/LC_IDENT...
7f47dd1af000-7f47dd1b1000 rw-p 00000000 00:00 0 
7f47dd1b1000-7f47dd1b2000 r--p 0002c000 fd:00 76867831  /usr/lib64/ld-2.28.so
7f47dd1b2000-7f47dd1b4000 rw-p 0002d000 fd:00 76867831  /usr/lib64/ld-2.28.so
7fff6435e000-7fff6437f000 rw-p 00000000 00:00 0         [stack]
7fff6438d000-7fff64391000 r--p 00000000 00:00 0         [vvar]
7fff64391000-7fff64393000 r-xp 00000000 00:00 0         [vdso]
ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0 [vsyscall]

The output confirms that the "pmap" command is using the "/proc/{id}/maps" pseudo file to generate report.

Table of Contents

 About This Book

 Introduction to Linux Systems

 Cockpit - Web Portal for Administrator

 Process Management

Memory Management

 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

 What Is Swap Space

 Virtual Memory Mapping and Page Table

 "ps -o rss,drs,trs,vsz,sz" - Process Status Options

 smem - Process Memory Usage Report

 pmap - Process Memory Map

/proc/{id}/maps - Process Memory Map

 /proc/{id}/smaps - Process Memory Map Details

 Files and Directories

 Users and Groups

 File Systems

 Block Devices and Partitions

 LVM (Logical Volume Manager)

 Installing CentOS

 SELinux - Security-Enhanced Linux

 Network Connection on CentOS

 Internet Networking Tools

 SSH Protocol and ssh/scp Commands

 Software Package Manager on CentOS - DNF and YUM

 vsftpd - Very Secure FTP Daemon

 LDAP (Lightweight Directory Access Protocol)

 Administrative Tasks

 References

 Full Version in PDF/EPUB