1

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

IVR Avenger
  • 325
  • 1
  • 5
  • 16
  • 1
    RH7.2? You're joking, right? On a 4G RAM machine? Why? – kmarsh Sep 01 '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 01 '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 01 '09 at 23:06

2 Answers2

4

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
nickthecook
  • 88
  • 1
  • 1
  • 6
0

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

duffbeer703
  • 20,797
  • 4
  • 31
  • 39