pmap Command
The pmap command reports the memory map of a process, showing how its virtual memory is allocated and what files or devices are mapped into its address space. It is a useful tool for debugging memory-related issues and understanding process behavior.
Syntax
Description
The pmap command displays the memory address space of a running process. For each process, it shows the virtual address, size, resident set size (RSS), dirty pages, and the mapping to files or devices. This information can help identify memory leaks, analyze shared library usage, and understand how a program uses memory.
Common uses include:
- Inspecting memory usage of a specific process.
- Identifying shared libraries loaded by a process.
- Debugging memory-related issues in applications.
- Understanding the virtual memory layout of a program.
Common Options
| Option | Description |
|---|---|
-x |
Extended format. Shows more details like RSS, dirty pages, and permissions. |
-d |
Show device format. Displays major:minor device numbers. |
-q |
Quiet mode. Suppress header and footer lines. |
-V |
Display version information. |
Examples
View memory map of a process
Displays the memory map for the process with PID 1234.
View memory map in extended format
Displays the memory map for PID 1234 with extended details, including RSS and dirty pages.
View memory map of a process by name (using pgrep)
Displays the memory map for all processes named 'apache2'.
Show memory map with device numbers
Displays the memory map for PID 1234, including major:minor device numbers.