{"id":466,"date":"2026-10-14T15:11:11","date_gmt":"2026-10-14T15:11:11","guid":{"rendered":"http:\/\/www.scmgalaxy.com\/tutorials\/2015\/12\/12\/20-pmap-commands-examples-in-linux-unix\/"},"modified":"2026-10-14T15:11:11","modified_gmt":"2026-10-14T15:11:11","slug":"20-pmap-commands-examples-in-linux-unix","status":"publish","type":"post","link":"https:\/\/www.devopsschool.com\/blog\/20-pmap-commands-examples-in-linux-unix\/","title":{"rendered":"Linux pmap Command Guide: Inspect Process Memory Maps with Practical Examples"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\"><em>Originally published on 2015-12-12; fully revised and updated.<\/em><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The <code>pmap<\/code> command reports the memory map of a running process. It is useful for Linux administrators, SREs, and developers who need more detail than <code>ps<\/code> or <code>top<\/code> provide. In this guide, you will learn when to use <code>pmap<\/code>, how to use its most common options, and how to build a simple troubleshooting workflow for memory investigations.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"600\" height=\"400\" src=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2015\/12\/pmap-commands-examples-in-l.png\" alt=\"pmap command examples in Linux\" class=\"wp-image-3162\" srcset=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2015\/12\/pmap-commands-examples-in-l.png 600w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2015\/12\/pmap-commands-examples-in-l-300x200.png 300w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Why use pmap instead of only ps or top<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Tools like <code>ps<\/code> and <code>top<\/code> are excellent for quick memory summaries, but they do not show the full mapping layout of a process. <code>pmap<\/code> helps you inspect mapped regions and totals in one place, which is useful when diagnosing unexpected growth or understanding how memory is allocated.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>Tool or path<\/th><th>Best for<\/th><th>Strength<\/th><th>Limitation<\/th><\/tr><\/thead><tbody><tr><td><code>pmap<\/code><\/td><td>Per-process mapping inspection<\/td><td>Shows mappings and totals in readable output<\/td><td>Focused on one process at a time<\/td><\/tr><tr><td><code>ps<\/code><\/td><td>Quick process memory summary<\/td><td>Fast snapshot (RSS\/VSZ and more)<\/td><td>No detailed mapping breakdown<\/td><\/tr><tr><td><code>top<\/code>\/<code>htop<\/code><\/td><td>Live monitoring<\/td><td>Continuous view of many processes<\/td><td>Not a deep memory map view<\/td><\/tr><tr><td><code>\/proc\/&lt;pid&gt;\/maps<\/code> and <code>\/proc\/&lt;pid&gt;\/smaps<\/code><\/td><td>Low-level detail<\/td><td>Very detailed kernel-provided data<\/td><td>Manual parsing can be time-consuming<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Basic pmap syntax and quick start<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The core syntax is simple: run <code>pmap<\/code> with a process ID (PID).<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-1\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php language-bash\"><span class=\"hljs-comment\"># Basic usage<\/span>\npmap <span class=\"hljs-number\">3724<\/span>\n\n<span class=\"hljs-comment\"># Find a PID first, then inspect it<\/span>\npgrep -n sshd\npmap $(pgrep -n sshd)<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-1\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p class=\"wp-block-paragraph\">For many builds of <code>pmap<\/code>, the output includes a final total line. That line is commonly used as a quick memory checkpoint.<\/p>\n\n\n<pre class=\"wp-block-code\"><span><code class=\"hljs language-bash\">pmap -x 3724 | tail -n 1<\/code><\/span><\/pre>\n\n\n<h2 class=\"wp-block-heading\">Common output modes and options<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The original article highlighted the most frequently used options below.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>Option<\/th><th>What it does<\/th><th>Typical use<\/th><\/tr><\/thead><tbody><tr><td><code>pmap &lt;pid&gt;<\/code><\/td><td>Shows default process mappings<\/td><td>Quick mapping overview<\/td><\/tr><tr><td><code>-x<\/code><\/td><td>Extended format with allocation details<\/td><td>Investigating RSS\/dirty-related detail per mapping<\/td><\/tr><tr><td><code>-d<\/code><\/td><td>Device format<\/td><td>Inspecting mapping\/device-oriented view<\/td><\/tr><tr><td><code>-q<\/code><\/td><td>Quiet mode (suppresses some header\/footer lines)<\/td><td>Scripting or compact output<\/td><\/tr><tr><td><code>-V<\/code><\/td><td>Shows program version<\/td><td>Checking behavior differences across environments<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n<pre class=\"wp-block-code\"><span><code class=\"hljs language-bash\">pmap 3526\npmap -x 3526\npmap -d 3526\npmap -q 3526\npmap -V<\/code><\/span><\/pre>\n\n\n<h2 class=\"wp-block-heading\">Memory investigation workflow with pmap<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">When an application appears to consume too much memory, use a repeatable flow so you can compare snapshots and avoid guesswork.<\/p>\n\n\n\n<pre class=\"mermaid\">\nflowchart TD\n    A[Alert high memory] --> B[Find target PID]\n    B --> C[Check quick metrics with ps]\n    C --> D[Run pmap -x for detailed map]\n    D --> E{Need device view}\n    E -- yes --> F[Run pmap -d]\n    E -- no --> G[Review totals and large mappings]\n    F --> G\n    G --> H[Repeat checks over time]\n<\/pre>\n\n\n\n<ul class=\"wp-block-list\"><li>Identify the target process PID.<\/li><li>Capture a quick summary with <code>ps<\/code> for baseline context.<\/li><li>Run <code>pmap -x<\/code> for extended mapping details.<\/li><li>Use <code>pmap -d<\/code> when device-oriented mapping context is needed.<\/li><li>Repeat periodically to detect growth patterns.<\/li><\/ul>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-2\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php language-bash\"><span class=\"hljs-comment\"># 1) Pick a target process (example: newest java process)<\/span>\npid=$(pgrep -n java)\n\n<span class=\"hljs-comment\"># 2) Quick baseline<\/span>\nps -p <span class=\"hljs-string\">\"$pid\"<\/span> -o pid,ppid,%mem,rss,vsz,cmd\n\n<span class=\"hljs-comment\"># 3) Detailed mapping snapshot<\/span>\npmap -x <span class=\"hljs-string\">\"$pid\"<\/span>\n\n<span class=\"hljs-comment\"># 4) Optional device-style view<\/span>\npmap -d <span class=\"hljs-string\">\"$pid\"<\/span>\n\n<span class=\"hljs-comment\"># 5) Track trend every 5 seconds<\/span>\nwatch -n <span class=\"hljs-number\">5<\/span> <span class=\"hljs-string\">\"pmap -x $pid | tail -n 1\"<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-2\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<h2 class=\"wp-block-heading\">How to read extended output safely<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">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 <code>procps<\/code> version, so always validate against your local man page.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>Common column<\/th><th>General meaning<\/th><th>Why it matters<\/th><\/tr><\/thead><tbody><tr><td>Kbytes (or Size)<\/td><td>Mapped size for region<\/td><td>Shows virtual allocation footprint<\/td><\/tr><tr><td>RSS<\/td><td>Resident memory in RAM<\/td><td>Helps explain physical memory pressure<\/td><\/tr><tr><td>Dirty<\/td><td>Modified pages<\/td><td>Useful when diagnosing write-heavy behavior<\/td><\/tr><tr><td>Mapping\/Mode<\/td><td>Path or type plus permissions<\/td><td>Identifies libraries, heaps, stacks, and files<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Reference<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Man page used in the original post: <a href=\"http:\/\/linux.die.net\/man\/1\/pmap\" target=\"_blank\" rel=\"noopener\">http:\/\/linux.die.net\/man\/1\/pmap<\/a><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Best practices and common pitfalls<\/h2>\n\n\n\n<ul class=\"wp-block-list\"><li>Always confirm option behavior with <code>man pmap<\/code> on the target host; output formats can vary by version.<\/li><li>Do not rely on a single snapshot for leak analysis; compare multiple samples over time.<\/li><li>Use <code>ps<\/code> or <code>top<\/code> first for triage, then <code>pmap<\/code> for deep inspection.<\/li><li>If you see permission errors, run with appropriate privileges or as the process owner.<\/li><li>When automating, prefer quiet\/structured parsing patterns and validate on each distribution you support.<\/li><\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Learn how to use the Linux pmap command to inspect per-process memory mappings, compare output modes, and troubleshoot high memory usage quickly. This updated guide includes workflow steps, command examples, and interpretation tips.<\/p>\n","protected":false},"author":1,"featured_media":3162,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_joinchat":[],"footnotes":""},"categories":[4957],"tags":[378,632,460,1298,1295,1296,1297,1300,1299,169],"class_list":["post-466","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-linux","tag-commands","tag-examples","tag-linux","tag-linux-pmap-command","tag-pmap","tag-pmap-command","tag-pmap-command-examples","tag-pmap-command-line","tag-pmap-commands-tutorials","tag-unix"],"_links":{"self":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/466","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/comments?post=466"}],"version-history":[{"count":5,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/466\/revisions"}],"predecessor-version":[{"id":79349,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/466\/revisions\/79349"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/media\/3162"}],"wp:attachment":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/media?parent=466"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/categories?post=466"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/tags?post=466"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}