[CentOS] How To Free memory

Stephen Harris lists at spuddy.org
Wed Jun 20 15:31:35 UTC 2007

On Wed, Jun 20, 2007 at 11:12:31PM +0800, Fung wrote:
> When the system is fresh reboot, there is below 1GB of used memory and as
> times go , the used memory increased to over 3.5GB.

Are you sure that the memory is really used?  Linux will take unused
memory and use it as a disk cache so if you read the same files again
and again then it will serve them from cache.  This makes things a lot

If you then start up a program that needs more memory Linux will shrink
the cache.  Because this is read-only data, the cache shrinking is very
quick and causes almost zero performance penalty (the standard memory
mapping algorithm can handle it).  As programs free up memory then the
cache will expand again.

So, on this PC:

             total       used       free     shared    buffers     cached
Mem:       1003316     941708      61608          0     267000     516808
-/+ buffers/cache:     157900     845416
Swap:      2024148      12324    2011824

The "Mem" lines says that I'm using 940Mb out of my 1Gb.  But the line
afterwards says that really only 157Mb is being used; the other 780Mb
is used for cache and buffers and is really "free" memory.

This "unified memory management" system is extremely powerful.  You just
need to be careful of what the numbers mean :-)



More information about the CentOS mailing list