82

I'm looking for somthing like top is to CPU usage. Is there a command line argument for top that does this? Currently, my memory is so full that even 'man top' fails with out of memory :)

98

From inside top you can try the following:

  • Press SHIFT+f
  • Press the Letter corresponding to %MEM
  • Press ENTER

You might also try:

$ ps -eo pmem,pcpu,vsize,pid,cmd | sort -k 1 -nr | head -5

This will give the top 5 processes by memory usage.

  • 18
    Under Linux, simply press M to sort by physical memory usage (RES column). Under *BSD, run top -o res or top -o size. But htop is a lot nicer and doesn't even consume more memory than top (however it's not part of the basic toolset so you might not have it installed). – Gilles Dec 19 '10 at 13:38
  • 2
    I had to press s to sort by %MEM and, then hit escape for top. – Bryce Guinta Jun 26 '16 at 20:40
11

If you have it installed I like htop once launching it you can press f6, down arrow (to MEM%), enter to sort by memory.

6

Once top starts, press F to switch to the sort field screen. Choose one of the fields listed by pressing the key listed on the left; you probably want N for MEM%

  • 2
    If you want MEM%, pressing 'M' does the same stated above. 'c' adds command line parameters to the process list, may be informative for your problem. – wag Dec 19 '10 at 8:46
6

In Solaris the command you would need is:

prstat -a -s size

This will list all processes in order of descending process image size. Note that the latter is based on memory committed to the process by the OS, not its resident physical memory usage.

There are supposedly versions of "top" available for Solaris, but these are not part of the standard installation.

5

One nice alternative to top is htop. Check it, it is much more user friendly than regular top.

1

This command will identify the top memory consuming processes:

ps -A --sort -rss -o pid,pmem:40,cmd:500 | head -n 6 | tr -s " " ";z"
0

You can try ps aux --sort -rss | head or ps aux | sort -nk +4 | tail

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.