8

I would like to leave an application running in my terminal that shows me the memory usage, similar to how top shows CPU and other info, and iotop shows the top I/O users.

Top and iotop

Does such an application exist?

P.S. I know top shows memory usage as well, but I'm talking about sorting by top memory usage and not showing any other info (similar to what iotop does).

3
  • In top press M and it will sort on memory usage. Is that what you're after?
    – popey
    May 26, 2012 at 15:05
  • I'm also slightly unclear what features you want/don't want, but htop is the top alternative I use. Although it sounds like maybe you are looking for fewer but more specific features rather than more features? May 26, 2012 at 15:16
  • @adempewolff exactly. For example iotop does what it says - shows the I/O usage of my applications and nothing else. I want to be able to run say, 'memtop` and just get memory usage %. htop is not what I'm looking for - because it shows other things (including CPU usage) that I already get from top. I mean, I like htop no doubt (I've used it before), but it's not what I'm looking for in this case.
    – RolandiXor
    May 26, 2012 at 17:30

4 Answers 4

8

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.
1
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!

2

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

1

htop is pretty great. It's reasonably lightweight (unlike gnome-system-monitor. It makes no sense to me that a system monitoring program should often be the most high-usage program.)

Push F6, then use the arrow keys or mouse to switch to sorting by MEM%.

1
  • 2
    While I like this answer, and htop (I've used it before) I'm looking for an app that follows the principle of doing one thing and doing it well (like iotop).
    – RolandiXor
    May 26, 2012 at 17:28

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .