Find the answer to your Linux question:
Results 1 to 6 of 6
Hello, I have a server with 12 GB of RAM that's basically using it all... [rootsrv ~]# free -m total used free shared buffers cached Mem: 11976 11881 95 0 ...
  1. #1
    Just Joined!
    Join Date
    Mar 2007
    Posts
    20

    Memory usage, ps output, etc.

    Hello,

    I have a server with 12 GB of RAM that's basically using it all...

    [rootsrv ~]# free -m
    total used free shared buffers cached
    Mem: 11976 11881 95 0 631 6011
    -/+ buffers/cache: 5238 6738
    Swap: 8191 20 8171
    [rootsrv ~]#

    Though the ps auxf output doesn't seem to add up to 100% usage... so I'm trying to determine where ALL of the memory is being used...

    ps auxf | awk 'BEGIN {FS=" "}{print $4" "$11" "$12" "$13" "$14" "$15}END {}' | sort -nr

    ... Is the command I've been using to sort %MEM usage for each process...

    Two main questions:

    1.) Is the ps auxf %MEM output total for every process supposed to correspond exactly with what's reported from free -m? Because there seems to be a discrepancy in terms of what ps auxf reports and what free -m reports, unless 0.0% MEM processes are rounded down...

    2.) Is there a way I can add all of the fields in the first columns with a for loop?

    Something along the lines of...

    for i in `ps auxf | awk 'BEGIN {FS=" "}{print $4" "$11" "$12" "$13" "$14" "$15}END {}' | sort -nr | cut -d ' ' -f1`; do ($i + $i); done

    Just to check if all of the %MEM percentages actually total near 100%?

    Thanks in advance for your assistance.

  2. #2
    Just Joined!
    Join Date
    Jul 2008
    Posts
    81
    Quote Originally Posted by agntsgotnosecret View Post
    Hello,

    I have a server with 12 GB of RAM that's basically using it all...

    [rootsrv ~]# free -m
    total used free shared buffers cached
    Mem: 11976 11881 95 0 631 6011
    -/+ buffers/cache: 5238 6738
    Swap: 8191 20 8171
    [rootsrv ~]#

    Though the ps auxf output doesn't seem to add up to 100% usage... so I'm trying to determine where ALL of the memory is being used...

    ps auxf | awk 'BEGIN {FS=" "}{print $4" "$11" "$12" "$13" "$14" "$15}END {}' | sort -nr

    ... Is the command I've been using to sort %MEM usage for each process...

    Two main questions:

    1.) Is the ps auxf %MEM output total for every process supposed to correspond exactly with what's reported from free -m? Because there seems to be a discrepancy in terms of what ps auxf reports and what free -m reports, unless 0.0% MEM processes are rounded down...

    2.) Is there a way I can add all of the fields in the first columns with a for loop?

    Something along the lines of...

    for i in `ps auxf | awk 'BEGIN {FS=" "}{print $4" "$11" "$12" "$13" "$14" "$15}END {}' | sort -nr | cut -d ' ' -f1`; do ($i + $i); done

    Just to check if all of the %MEM percentages actually total near 100%?

    Thanks in advance for your assistance.
    Why invoke another program when awk will do the job for you.
    ps auxf | awk '{sum += $4; print sum, $4, $11, $12, $13, $14, $15}'

    If you want it sorted before summing,
    ps auxf | sort -k4nr | awk '{sum += $4; print sum, $4, $11, $12, $13, $14, $15}'

  3. #3
    Linux Enthusiast Mudgen's Avatar
    Join Date
    Feb 2007
    Location
    Virginia
    Posts
    623
    The -/+ buffers/cache: line is telling you that your processes are using less than half your memory. Modern Linux kernels will suck up free memory for use as buffer/cache, and free the memory up as needed by processes.

    Trying to account for memory like it was your checkbook, particularly reconciling numbers reported by different programs, will drive you nuts. Or would me.

  4. #4
    Just Joined! bclark4444's Avatar
    Join Date
    Dec 2003
    Posts
    55
    greyhairweenie is right, Linux utilizes memory in complex ways and trying to break it down to a simlistic view will drive a person insane. The philosophy is simple though: unused RAM is a waste of resources, so the kernel uses it for anything and everything that it can. As a side note: dont try and reconcile the swap area either because a process can exist in RAM, swap, or both areas at the same time.

    I wouldnt worry too much about RAM until my vmstat begins showing large numbers of blocks being swapped in and out. Thats when there is a problem.

    --Brett

  5. #5
    Linux Enthusiast Mudgen's Avatar
    Join Date
    Feb 2007
    Location
    Virginia
    Posts
    623
    And likewise like he said, regarding swap.

  6. #6
    Just Joined!
    Join Date
    Mar 2007
    Posts
    20
    Thanks for the information, guys... very informative.

    Next time I'll try to not take the easy way out and RTFM. lol

    Again, thank you.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...