Use the simple `pmap` snapshot to spot which memory segments grow and find leaks fast. 16.11.2025 | reading time: 3 min pmap prints a process memory map and a concise summary so he can quickly spot which segment grows; this article shows how to run `pmap -x PID`, read the columns and use it as a first-line leak detective. Reproduce a leak and observe Start a small leaking process, get its PID and snapshot memory: `python3 -c "a=[]; import time; [a.append('x'*1024*1024) for _ in range(50)]; time.sleep(600)" &`; find PID: `pgrep -f "python3 -c"`; first snapshot: `pmap -x 12345` Output: "12345: total 2048K; 0000555555554000 1024K 256K 0 rw-p [heap]"; after allocations repeat `pmap -x 12345` Output: "12345: total 52224K; 0000555555554000 49152K 49152K 0 rw-p [heap]" — the heap line increased dramatically, a clear sign of a leak. Decode what pmap shows `pmap -x` prints columns for mapping size, RSS and Dirty pages plus permissions and name; the important clue is the RSS column for anonymous mappings such as [heap] or a malloc arena: growing RSS on the same mapping across snapshots means resident memory is being retained. Quick options and workflows Use `pmap -x PID` for extended info and run repeatedly with tools such as `watch -n 2 pmap -x PID` to watch trends; when a mapping grows, inspect `/proc/PID/smaps` for per-map details and use `ps`, `top` or `smem` to cross-check totals. When to dig deeper If `pmap` points to a leaking mapping, move to alloc-level tools: run Valgrind Massif for heap profiling, use Heaptrack for allocation stacks or attach `gdb` to inspect the allocator state; combine those with application logs to find the guilty allocation site. A practical next step Start using `pmap` as part of your troubleshooting routine: snapshot, watch, and when you see growing RSS on anonymous mappings escalate to heap profilers; keep practicing and consider formal study to deepen skills and prepare for certifications such as CompTIA Linux+ or LPIC-1 with intensive exam preparation at bitsandbytes.academy. Join Bits & Bytes Academy First class LINUX exam preparation. processes troubleshooting utilities