Need help?

Our experts will login to your server within 30 minutes to fix urgent issues.

Customer support or server support, make your own solution using our support configuration wizard.

Who eats all your RAM?

Have you ever wondered as to where all your server memory is getting used up? Have you noticed growing web-server processes and wondered if the process is actually using up all the memory?
Do you want to find how much memory is used exclusively by a process? The simple “ps” command can get you the memory details per process, but it’s not that straight forward as you imagine.


Hire Bobcares Linux Server Administrators
Get super reliable servers and delighted customers

See how we do it!



Lets have a look at the memory related section in the man page of ps.


%mem%MEMratio of process’s resident set size to physical memory on the machine, expressed as a percentage(alias pmem).
resident set size, the non-swapped physical memory that a task
has used (in kiloBytes). (alias rssize, rsz)
virtual memory size of the process in KiB (1024-byte units). Device mappings are currently excluded; this is subject to change. (alias vsize)


Mostly, one uses “ps aux” to list the processes, and it provides all the 3 fields mentioned above.

USER    PID    %CPU    %MEM    VSZ        RSS    TTY    STAT    START    TIME    COMMAND
root       1       0.0          0.0        3084       612     ?       Ss         13:10    0:02     /sbin/init


Linux newbies consider either VSZ or RSS value as the memory used by that process. However, VSZ value is the total memory used by a process including shared objects. In other words, it’s the memory used by a process, if that was the only process running in the server. Shared objects, are as the name suggests, shared by many processes. RSS is the portion of a process’s memory that is held in RAM. The rest of the memory exists in swap.


Now if you want to find the exclusive memory usage by the process, pmap is the command that you need. The pmap command (with -d flag) will report the memory map of a process. You can find 3 values at the very end of the output, as given below.

mapped: total memory mapped for a process

writeable/private: exclusive memory used by a process

shared: memory used by shared objects

$ pmap -d 3258
3258: /usr/lib/opera/10.10/opera
Address Kbytes Mode Offset Device Mapping
08048000 12500 r-x– 0000000000000000 008:00003 opera
08c7d000 36 rw— 0000000000c35000 008:00003 opera
b6f5b000 936 r-x– 0000000000000000 008:00003
b7047000 8 rw— 00000000000eb000 008:00003
b7049000 4 rw— 00000000b7049000 000:00000 [ anon ]
b704a000 7112 r-x– 0000000000000000 008:00003
b773c000 256 rw— 00000000006f1000 008:00003
bfac8000 80 rwx– 00000000bffeb000 000:00000 [ stack ]
bfadc000 4 rw— 00000000bffff000 000:00000 [ anon ]

mapped: 224204K writeable/private: 164972K shared: 312K

I have left out few lines from the output. The rest is similar to what you actually find above. We can see some interesting facts from the above output. The ones that start with “lib” are shared libraries, and they are listed twice, for its code segment and data segment. The code segment has a mode of “r-x–“, while the data is set to “rwx–“.


You see code segment use most of the allotted memory. Now that is good, since they are the ones that can be shared between processes. If you consider that all of the shared libraries are already loaded, for say another similar process, you can ignore the shared memory usage from this process. In short, you can look at “writeable/private” field to find the memory exclusively allotted for the process.


The tool should help you analyze say an apache process, and hence calculate the parameters such as “MaxClients” for tweaking apache for best performance. You could analyze an application for it’s memory mapping and compare different applications. While doing so, you should remember that there are other important factors, like cpu and disk I/O etc, that will affect your application’s performance.

About the Authors :

Mohammed Abdurahiman joined Bobcares in December 2006, and is an expert in shell scripting. System Administration and troubleshooting is ingrained in him. He also follows popular linux forums and contributes to the open source community. Mohammed Abdurahiman is an asset to Bobcares because of his keen interest on improving systems and innovative suggestions. During his free time, Mohammed loves to blog, read technical articles and watch football.


Sankar works as a Senior Software Engineer in Bobcares. He joined Bobcares back in April 2006. He loves grooming/mentoring people. During his free time, he listens to music, and enjoys singing..

Bobcares is a server management company that helps businesses deliver uninterrupted and secure online services. Our engineers manage close to 51,500 servers that include virtualized servers, cloud infrastructure, physical server clusters, and more.