Is there an application that can show memory usage in a similar manner to top?

Solution 1:

The closest I could find is memtop, a Python script available here on Google Code.

Screenshot: enter image description here

How to use memtop

  • It's a Python script, so simply do a sudo mv memtop-1.0.0.py /usr/bin/memtop.py and a chmod +x /path/to/memtop.py to make it executable
  • Default update period is 15 min; use switch -p 1 to make it 1 minute, etc. (can't go lower than that unless you modify the source)
  • Use -l N, where N is the number of processes you want to show, depending on the size of your terminal.
  • Use -m to show "more" information, i.e. the Swap/Page stats at the bottom of the screenshot.

The htop disguised as memtop option

If you don't use htop otherwise, it's pretty easy to set it up with the F2-setup option to look like memtop:

enter image description here

  • htop config is stored in ~/.config/htop/htoprc, so just delete htoprc to restore normal htop.

Solution 2:

I don't know about any specific application for monitoring what you want in real time but I did find some information that might be helpful.

First heres a simple command to print this info ps -e -orss=,args= | sort -b -k1,1n | pr -TW$COLUMNS (found here: http://www.linuxquestions.org/questions/linux-general-1/how-to-show-the-memory-usage-per-process-160181/)

Second here is some more info about scripts to do the same:

http://unixlive.editboard.com/t4-memory-usage-retrieval-on-linux-process-wise-and-general

and

http://unixlive.editboard.com/t5-how-much-ram-is-used-per-program

You could write your own script/program to meet your needs. The info you need is all updated in /proc/ in realtime, but you have to solve two problems:

  1. I doubt there is any one file listing all the processes and their memory usage in real time. Instead every process has it's own files (in /proc/[pid]/), and some of the potential files for finding this info are not human readable--although I suspect that statm and status have the necessary info and are both human readable.
  2. Displaying all this information in realtime. I know very little about bash scripting or programming but to display the information in realtime you would need to use something like a lot of tail commands with a pipe to sort/print only the desired information for each process.

Not really a complete answer, but hopefully this gives you some ideas of what you could try. Good luck!

Solution 3:

Try watch memstat -w or perhaps watch free -m .