Ubuntu Tutorials - Herong's Tutorial Examples - v1.25, 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 Ubuntu 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$ pmap 2666 2666: /usr/bin/gnome-software --gapplication-service 000055a0683b7000 948K r-x-- gnome-software 000055a0686a4000 20K r---- gnome-software 000055a0686a9000 4K rw--- gnome-software 000055a06a349000 62240K rw--- [ anon ] 00007faba8000000 21900K rw--- [ anon ] 00007faba9563000 43636K ----- [ anon ] ... 00007fabbb539000 20K r-x-- libnss_dns-2.27.so 00007fabbb53e000 2048K ----- libnss_dns-2.27.so 00007fabbb73e000 4K r---- libnss_dns-2.27.so ... total 1345196K
The output shows that:
2. Report virtual memory map in the extended format, which provides 2 extra output fields and field headers.
herong$ pmap -x 1998 2666: /usr/bin/gnome-software --gapplication-service Address Kbytes RSS Dirty Mode Mapping 000055a0683b7000 948 504 0 r-x-- gnome-software 000055a0683b7000 0 0 0 r-x-- gnome-software 000055a0686a4000 20 20 20 r---- gnome-software ... 000055a06a349000 62240 53152 53152 rw--- [ anon ] 000055a06a349000 0 0 0 rw--- [ anon ] 00007faba8000000 21900 17352 17352 rw--- [ anon ] ... 00007fabbb539000 20 20 0 r-x-- libnss_dns-2.27.so 00007fabbb539000 0 0 0 r-x-- libnss_dns-2.27.so 00007fabbb53e000 2048 0 0 ----- libnss_dns-2.27.so ... total kB 1345196 162228 150928
Compare "pmap", "ps" and "smem" Reports - Here are the outputs of "pmap", "ps" and "smem" commands on process id 2666 (gnome-software).
herong$ pmap -x 2666 ... Address Kbytes RSS Dirty Mode Mapping total kB 1345196 162228 150928 herong$ smem -P gnome-software PID User Command Swap USS PSS RSS 2666 herong /usr/bin/gnome-software --g 87120 153740 154670 162228 herong$ ps -o pid,euser,%mem,rss,drs,trs,sz,vsz,comm | grep 2666 PID EUSER %MEM RSS DRS TRS SZ VSZ COMMAND 2666 herong 4.3 161300 1344245 946 336298 1345192 gnome-software
Those outputs show that 3 commands report slightly different numbers. I am not sure why.
Table of Contents
Introduction to Ubuntu Systems
GNOME - Desktop Interface and Environment
Shell - The Command-Line Interpreter
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
earlyoom - A Simple OOM Killer