Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

When I use the "top" command on my Red Hat 7.2 machine, it tells me that ~3.9 out of 4.0 gigs of RAM are in use, and that there's about 135meg free.

When I use the "ps" command, however, to list all processes and their memory utilization, the list only adds up to about 650megs.

Is this expected behavior, or is there something going on that should be cause for concern? I read that Linux will use free RAM to cache frequently used files from the disk, could that account for the "missing" RAM utilization?

Thanks!
IVR Avenger

share|improve this question
1  
RH7.2? You're joking, right? On a 4G RAM machine? Why? –  kmarsh Sep 1 '09 at 20:29
    
Your comment does not fill me with confidence. :-) It's a box that we inherited as a quasi appliance; it's been sourced, installed, and configured by an external vendor, but they don't really know too much about it. What's so unusual about the configuration? –  IVR Avenger Sep 1 '09 at 22:07
1  
RH7.2 is ancient. It's 8 years old at this point, seeing it on anything that powerful is kind of odd. –  Cian Sep 1 '09 at 23:06

2 Answers 2

up vote 3 down vote accepted

Your guess is most likely correct.

The "free memory" number given by top does not include what is used for the filesystem cache or buffers. The memory allocated to filesystem cache is free in that if an process needed some of it, it could easily be made available, but top will not show you this.

free -m

will give you a better idea of how much memory your processes are actually using (in MB), on the "-/+ buffers/cache" line.

Of course, it still won't likely equal your calculations based on the output of ps exactly, because calculating memory usage in Linux is tricky, especially around shared memory.

In the following example, 1287MB is much more accurate as a view of free memory than 31MB.

$ free -m
             total       used       free     shared    buffers     cached
Mem:          2002       1970         31          0         48       1207
-/+ buffers/cache:        714       1287
Swap:         1027          3       1023
share|improve this answer

top often has problems with over-reporting shared memory; a perfect example of this phenomena is a Java Application Server or apache.

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.