LinuxCommandLibrary

pmap

Report memory map of a process

TLDR

Print memory map for a specific process ID (PID)

$ pmap [pid]
copy

Show the extended format
$ pmap --extended [pid]
copy

Show the device format
$ pmap --device [pid]
copy

Limit results to a memory address range specified by low and high
$ pmap --range [low],[high]
copy

Print memory maps for multiple processes
$ pmap [pid1 pid2 ...]
copy

SYNOPSIS

pmap [options] pid...

PARAMETERS

-x
    Extended format. Shows more detailed information about each mapping, including permissions, offset, and device.

-d
    Display memory usage in device format.

-q
    Quiet mode. Suppresses the header line.

-A
    Display the address space layout.

-p
    Print private and shared mappings separately.

-X
    Even more extended format. Shows maximum information about each mapping.

-n
    Display memory mappings in numerical order.

-h
    Display help message and exit.

pid
    The process ID (PID) of the process to inspect. Multiple PIDs can be specified.

DESCRIPTION

The pmap command in Linux is used to report the memory map of a process. It provides information about the different memory regions a process uses, including the starting and ending addresses, size, protection (read, write, execute), and the mapped file or device (if any). This tool is invaluable for understanding how a process is utilizing memory, debugging memory-related issues like memory leaks or excessive memory consumption, and analyzing performance bottlenecks related to memory access. It offers insights into the process's address space layout, revealing how code, data, shared libraries, and heap are organized. PMAP supports various formatting options and can target a process by its PID. Output can include both individual mapped regions and a summary of memory usage.

CAVEATS

The information provided by pmap reflects the process's memory map at the exact moment the command is executed. It's a snapshot, and the memory map can change rapidly as the process runs.
Root privileges might be required to view the memory map of processes owned by other users.

OUTPUT INTERPRETATION

The output of pmap typically shows the address range, size, RSS (Resident Set Size), dirty pages, and the file or device mapped to each memory region. Understanding these values is crucial for effective memory analysis.
RSS indicates the amount of memory actually held in RAM. Dirty memory is the memory which has been modified.

USING WITH PID

The core functionality relies on targeting a running process identified by its PID. You can discover the PID using commands like ps or top.

HISTORY

pmap is a part of the procps or procps-ng packages, widely available on Linux distributions. Its origins are rooted in the need for system administrators and developers to understand and analyze memory usage of processes. Over time, it has been improved with different options for viewing memory usage in different formats.

SEE ALSO

ps(1), top(1), free(1), vmstat(8), proc(5)

Copied to clipboard