Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

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

I have an rails 3 application with 100-200 daily unique visitors. The total memory consumed on the server(Ubuntu) is around 1.5-2 GB. I want to know how much memory is used by each process. What are the best tools to track memory used by different processes?

share|improve this question

migrated from Oct 12 '11 at 2:59

This question came from our site for professional and enthusiast programmers.

You could just fire up top and press M to sort processes by memory usage.

You could run ps vax | sort -k8n to show processes sorted by the resident stack usage (ps v switches to a memory-centric view).

You could enable snmp and configure mrtg to periodically poll the system, generating a graph of how much memory is used by the processes you care about.

You could resign yourself to the knowledge that Ruby, for all its benefits, is terrible at managing memory in long-running processes. :)

You could combine a more complicated ps command line (look at the man page, and read about the -o option) and rrdtool with a shell script to generate historical statistics on the processes you care about.


share|improve this answer
htop is a nice extension of top using colours to enhance the readability and provide more info. It's interface is otherwise quite similar to top – drevicko Dec 19 '11 at 0:09
+1 for letting me know ps vax, for better view ps vax | sort -k8n | tail can be used. – Vishnu Kumar Mar 8 '13 at 8:04

Memory management is very difficult, but you can use top, htop or, as dannysauer suggests, something like ps vax | sort -k8n. If you want to get an overview/summary, then free -m is nice.

But it is common for processes to consume less memory than they use. For instance, if you have ten processes using 10MB each, that does not mean those processes will consume 100MB. The reason for this is that Linux will recognize identical memory portions between processes so you don't need to have many identical copies. In other words, your system can always use more memory than you have. So you really need to separate between memory consumption and memory usage.

It's not always easy.

share|improve this answer

Your Answer


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