6

I need a way to see how many bytes to top ten processes are using not percentage. I am using centos

David
  • 295
  • 4
  • 10
  • Your question is vague and ambiguous. Are you asking about *physical* memory? – David Schwartz Aug 27 '11 at 15:29
  • yes, I want to know how many bytes the top programs are using so I can monitor it over time and figure out why the resources are growing and on what. – David Aug 27 '11 at 16:12

3 Answers3

8

it would be better to use ps with head

ps aux --sort -rss | head -10

The RSS field shows physical memory usage in KB.

David Schwartz
  • 31,215
  • 2
  • 53
  • 82
Mike
  • 21,910
  • 7
  • 55
  • 79
3

I just notice that rss is in kiloBytes.

I created an awk script to print sizes in human readable format:

#!/usr/bin/awk

{
    hr[1024**2]="GB"; hr[1024]="MB";
    for (x=1024**3; x>=1024; x/=1024) {
        if ($1>=x) {
            printf ("%-6.1f %s ", $1/x, hr[x]); break
        }
    }
}
{ printf ("%-6s %-10s ", $2, $3) }
{ for ( x=4 ; x<=NF ; x++ ) { printf ("%s ",$x) } print ("") }

and pipe the ps output to:

$ ps --no-headers -eo rss,pid,user,command --sort -rss | head -10 | awk -f topmem.awk

quanta
  • 50,327
  • 19
  • 152
  • 213
2

top and hit M sorts by resident memory usage. Quickest and easiest I know of.

womble
  • 95,029
  • 29
  • 173
  • 228