MYHOSPITALNOW.COM

Find Trusted Doctors & Hospitals

Discover healthcare providers, compare hospitals, and explore treatment options worldwide.

Free Treatment Quotes • Doctor Search • Hospital Comparison

Find Healthcare Options

www.myhospitalnow.com

Linux pmap Command Guide: Inspect Process Memory Maps with Practical Examples

Originally published on 2015-12-12; fully revised and updated.

The pmap command reports the memory map of a running process. It is useful for Linux administrators, SREs, and developers who need more detail than ps or top provide. In this guide, you will learn when to use pmap, how to use its most common options, and how to build a simple troubleshooting workflow for memory investigations.

pmap command examples in Linux

Why use pmap instead of only ps or top

Tools like ps and top are excellent for quick memory summaries, but they do not show the full mapping layout of a process. pmap helps you inspect mapped regions and totals in one place, which is useful when diagnosing unexpected growth or understanding how memory is allocated.

Tool or pathBest forStrengthLimitation
pmapPer-process mapping inspectionShows mappings and totals in readable outputFocused on one process at a time
psQuick process memory summaryFast snapshot (RSS/VSZ and more)No detailed mapping breakdown
top/htopLive monitoringContinuous view of many processesNot a deep memory map view
/proc/<pid>/maps and /proc/<pid>/smapsLow-level detailVery detailed kernel-provided dataManual parsing can be time-consuming

Basic pmap syntax and quick start

The core syntax is simple: run pmap with a process ID (PID).

# Basic usage
pmap 3724

# Find a PID first, then inspect it
pgrep -n sshd
pmap $(pgrep -n sshd)Code language: PHP (php)

For many builds of pmap, the output includes a final total line. That line is commonly used as a quick memory checkpoint.

pmap -x 3724 | tail -n 1

Common output modes and options

The original article highlighted the most frequently used options below.

OptionWhat it doesTypical use
pmap <pid>Shows default process mappingsQuick mapping overview
-xExtended format with allocation detailsInvestigating RSS/dirty-related detail per mapping
-dDevice formatInspecting mapping/device-oriented view
-qQuiet mode (suppresses some header/footer lines)Scripting or compact output
-VShows program versionChecking behavior differences across environments
pmap 3526
pmap -x 3526
pmap -d 3526
pmap -q 3526
pmap -V

Memory investigation workflow with pmap

When an application appears to consume too much memory, use a repeatable flow so you can compare snapshots and avoid guesswork.

flowchart TD
    A[Alert high memory] --> B[Find target PID]
    B --> C[Check quick metrics with ps]
    C --> D[Run pmap -x for detailed map]
    D --> E{Need device view}
    E -- yes --> F[Run pmap -d]
    E -- no --> G[Review totals and large mappings]
    F --> G
    G --> H[Repeat checks over time]
  • Identify the target process PID.
  • Capture a quick summary with ps for baseline context.
  • Run pmap -x for extended mapping details.
  • Use pmap -d when device-oriented mapping context is needed.
  • Repeat periodically to detect growth patterns.
# 1) Pick a target process (example: newest java process)
pid=$(pgrep -n java)

# 2) Quick baseline
ps -p "$pid" -o pid,ppid,%mem,rss,vsz,cmd

# 3) Detailed mapping snapshot
pmap -x "$pid"

# 4) Optional device-style view
pmap -d "$pid"

# 5) Track trend every 5 seconds
watch -n 5 "pmap -x $pid | tail -n 1"Code language: PHP (php)

How to read extended output safely

Extended output commonly includes columns such as size, resident pages, and dirty memory per mapping. Exact column names and availability may differ by Linux distribution and procps version, so always validate against your local man page.

Common columnGeneral meaningWhy it matters
Kbytes (or Size)Mapped size for regionShows virtual allocation footprint
RSSResident memory in RAMHelps explain physical memory pressure
DirtyModified pagesUseful when diagnosing write-heavy behavior
Mapping/ModePath or type plus permissionsIdentifies libraries, heaps, stacks, and files

Reference

Man page used in the original post: http://linux.die.net/man/1/pmap

Best practices and common pitfalls

  • Always confirm option behavior with man pmap on the target host; output formats can vary by version.
  • Do not rely on a single snapshot for leak analysis; compare multiple samples over time.
  • Use ps or top first for triage, then pmap for deep inspection.
  • If you see permission errors, run with appropriate privileges or as the process owner.
  • When automating, prefer quiet/structured parsing patterns and validate on each distribution you support.

Find Trusted Cardiac Hospitals

Compare heart hospitals by city and services — all in one place.

Explore Hospitals
I'm Rajesh Kumar, a DevOps, SRE, DevSecOps, Cloud, and Platform Engineering expert passionate about sharing practical knowledge, real-world experiences, and industry best practices. I have worked at Cotocus and regularly write about technology, travel, investing, health, product reviews, and digital marketing through my various platforms. I publish technical articles at DevOps School, travel stories at Holiday Landmark, stock market insights at Stocks Mantra, health and fitness guidance at My Medic Plus, product reviews at TrueReviewNow, and SEO and digital marketing strategies at Wizbrand.

Related Posts

How to set Static IP Address in Ubuntu?

On current Ubuntu Server releases, you set a static IP address in a Netplan YAML file under /etc/netplan/, then apply it with sudo netplan apply. The example…

Read More

How to Install Ruby on Linux

You can install Ruby on Linux with your distribution's package manager (apt on Ubuntu and Debian, dnf on RHEL, Rocky, AlmaLinux and Fedora). If you need a…

Read More

Newrelic Tutorials: How to Integrate Apache2 in ubuntu

This tutorial shows how to monitor Apache HTTP Server (apache2) on Ubuntu with the New Relic Apache integration. It covers installing Apache, exposing the mod_status page that…

Read More

Kapitan Tutorial: How to install Kapitan?

Kapitan is an open-source tool from Kapicorp for templated configuration management. It builds Kubernetes manifests, Terraform files, scripts and documentation from one inventory, and it can handle…

Read More

Packer Tutorials: Packer Install and configurations

HashiCorp Packer is a single binary that builds machine images (AMIs, Azure images, Docker images, VMware templates and more) from one HCL template. The commands above install…

Read More

How to install Kapitan in Windows using wsl?

Kapitan is a Python-based configuration management tool, and on Windows it runs best inside the Windows Subsystem for Linux (WSL). This guide fills in the commands the…

Read More
Subscribe
Notify of
guest
1 Comment
Newest
Oldest Most Voted
Puja kushwaha
Puja kushwaha
1 month ago

The pmap command is useful for understanding how a Linux process uses memory. It helps show mapped memory regions, but the output makes more sense when compared with tools like ps or top. Checking a process before and after a workload can reveal changes in memory use. Keep in mind that mapped memory does not always equal actual physical RAM use. Combining these tools gives a clearer view when tracking memory issues.

1
0
Would love your thoughts, please comment.x
()
x