Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How can I get the current memory usage for all running processes individually? Preferably in bytes so they can be added up accurately. Can I roll up the summaries for child processes into the process that spawned them? (e.g all apache threads together).

Sometimes, my server runs out of memory and becomes unresponsive. I want to discover what is using up all the memory. Unfortunately, it's likely to not be a single process. Some programs spawn hundreds of processes, each using very little memory, but it adds up.

share|improve this question

This will get you part of the way there:

ps axfo %mem,size,rss,vsz,pid,args

By the way, Apache is probably preforked instead of threaded.

share|improve this answer
Cool command. Yes, it's prefork. Unfortunately, the httpd processes come out a little chaotic, none of them grouped under the process that started them. pstree doesn't group them either. Best I can do is to group them by name. – Nick Retallack Mar 23 '10 at 1:49
ps aux

There is a column called RSS, which is the non-swapped memory usage in kilobytes. I had to parse the output of this command and add it up myself to find out the total per command name.

share|improve this answer

I present smem, which introduces the concept of Proportional Set Size:

Because large portions of physical memory are typically shared among multiple applications, the standard measure of memory usage known as resident set size (RSS) will significantly overestimate memory usage. PSS instead measures each application's "fair share" of each shared area to give a realistic measure.

Alternatively, you can just look for oomkiller logs, it'll tell you what program got killed for breaking the camel's back in memory allocation.

share|improve this answer
Cool info. I don't have this command though. – Nick Retallack Mar 23 '10 at 1:52
The website comes with source code, dude. – jldugger Mar 23 '10 at 2:04

You do not tell what Unix you are running. If it is Solaris, you can use the prstat command which have some useful options, like:

prstat -s rss -a # sorted by RAM usage, per user metrics
share|improve this answer
I didn't mention it because it's CentOS :P – Nick Retallack Mar 23 '10 at 1:53

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.