Find out Process Memory Consumption with pmap

On Linux dedicated servers, each instance of any running software is called a process. There can be tens or even hundreds of processes running at any given time, and some processes, such as Apache web server, will spawn child processes. Each process in Linux is assigned an identification number, also known as a PID. To find out any PID, you can run the ps command. For example, “ps aux” will display all running processes, including the PIDs.

Once you know the process ID, you can find out how much memory a particular process is using through the pmap command. For example, if the process ID is 16940, you would find out its memory consumption with:

pmap -d 16940

The output will look something like:

Address Kbytes Mode Offset Device Mapping
00199000 108 r-x-- 0000000000000000 008:00001
001b4000 4 r---- 000000000001a000 008:00001
001b5000 4 rw--- 000000000001b000 008:00001
001ec000 208 r-x-- 0000000000000000 008:00001
00220000 4 ----- 0000000000034000 008:00001
00221000 8 r---- 0000000000034000 008:00001
00223000 4 rw--- 0000000000036000 008:00001
00224000 1356 r-x-- 0000000000000000 008:00001

This will display the complete memory usage of every command, file, and library associated with the process. This is a good way to find out exactly what may be causing high memory consumption in a runaway process and whether or not it is something you can fix.

Like most Linux commands, pmap is free and open source. You can find out more about it by typing “man pmap” from the command line.