Reporting memory usage per process/program

memoryperformance-monitoringunix

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.

Best Answer

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.