Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

How can I display the top results in my terminal in real time so that the list is sorted by memory usage?

share|improve this question

3 Answers 3

Use quick tip using top command in linux/unix

top

hit Shift + f, then choose the display to order by memory usage by hitting key n then press Enter. You will see active process ordered by memory usage.

Or you can just press M after running the top command.

On OS X 10.10 the command top -o MEM seems to work.

References

http://stackoverflow.com/questions/4802481/how-to-see-top-processes-by-actual-memory-usage

share|improve this answer
3  
Does not work for me –  jan Mar 5 at 11:09

The command line option -o (o standing for "Override-sort-field") also works on my Xubuntu machine and according to the Mac man page of top it should work on a Macintosh too. If I want to short by memory usage I usually use

top -o %MEM

which sorts by the column %MEM. But I can use VIRT, RES or SHR too. On a Macintosh I would probably use mem or vsize.

I don't know why or how but this is pretty much different between Unix systems and even between Linux distributions. For example -o isn't even available on my Raspberry running Wheezy. It may be worth give it a try though.

share|improve this answer
1  
The answer could user more clarity: %MEM is given as an answer to the eager reader; while it doesn't work everywhere (by far). –  7heo.tk May 6 at 15:00
    
For Macbook 2014 this is saying: top -o %MEM invalid argument -o: %MEM –  advocate Jun 1 at 17:43
    
I'm sorry to hear that. –  ytg Jun 1 at 20:03

It seems like the -o flag will take the actual column name. So if the top command shows only "mem" then the command should be "top -o mem".

For the ubuntu machine I am testing with, the column is called "%MEM". On the OSX Yosemite I tried, it is "mem".

share|improve this answer

Your Answer

 
discard

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.