pmap is a command-line utility in Linux/Unix systems that reports the memory mapping of a process or processes. It displays the memory usage of a process in a detailed and comprehensive manner. This can be useful for analyzing the memory usage of a process, identifying memory leaks, and optimizing memory usage.
The pmap command reports the amount of memory that one or more processes are using. For example, use this command to determine which processes on the server are being allocated memory and whether this amount of memory is a cause of memory bottlenecks:
# pmap -x [pid]
Example below shows the total amount of memory the cupsd process is using:
# pmap -x 1796 1796: /usr/sbin/cupsd Address Kbytes RSS Anon Locked Mode Mapping 08048000 244 - - - r-x-- cupsd ffffe000 4 - - - ----- [ anon ] -------- ------- ------- ------- ------- total kB 6364 - - -
If you encounter the below error while running the command pmap:
pmap: command not found
you may try installing the below package as per your choice of distribution:
Distribution | Command |
---|---|
Debian | apt-get install procps |
Ubuntu | apt-get install procps |
Alpine | apk add procps |
Arch Linux | pacman -S procps-ng |
Kali Linux | apt-get install procps |
CentOS | yum install procps-ng |
Fedora | dnf install procps-ng |
Raspbian | apt-get install procps |
pmap Command Examples
1. Print memory map for a specific process id (PID):
# pmap pid
2. Show the extended format:
# pmap --extended pid
3. Show the device format:
# pmap --device pid
4. Limit results to a memory address range specified by `low` and `high`:
# pmap --range low,high
5. Print memory maps for multiple processes:
# pmap pid1 pid2 ...