[CentOS] free

Wed Jul 14 19:49:13 UTC 2010
Flaherty, Patrick <pflaherty at wsi.com>

> -----Original Message-----
> From: centos-bounces at centos.org [mailto:centos-bounces at centos.org] On
> Behalf Of Keith Keller
> Sent: Monday, July 12, 2010 10:41 AM
> To: CentOS mailing list
> Subject: Re: [CentOS] free
> 
> On Mon, Jul 12, 2010 at 10:15:06AM -0400, Jason Pyeron wrote:
> > The man page does not say much, but does this mean I have only
396668
> > used by programs (used-cached)?
> >
> > Or shoul I be reading the 2nd line?
> 
> Yes, you should be reading the second line.
> 
> > [root at ten-212 ~]# free
> >              total       used       free     shared    buffers
> cached
> > Mem:       7918844    5478820    2440024          0     111684
> 5082152
> > -/+ buffers/cache:     284984    7633860
> > Swap:      9961464        204    9961260
> 
> This first line includes all files that are being cached in memory
(for
> faster reading if needed later, for example).  That memory will be
> freed up if needed.  The second line doesn't include that cache, so is
> a better indicator of actual memory use.
> 
> (And on that first line, "cached" is already part of "used", so your
> free memory counting the cache is 2440024; it's just provided for
> informational purposes.)

I did some testing a while back, and my results showed that the -/+
buffers line seemed to be the *Minimum* amount of ram available if the
kernel purged it's buffers/cache. Sometimes more is available.

(Roughly) The test was:
* Turn swap off
* Run free
* Run 20 instances of a test program that malloc'd 100 megs of ram
* Run free, see 2 gigs of ram + orginal amount of ram used.
* Kill N number of those programs, which should free up N*100megs
* Run free, output of -/+ did not reflect 2gigs - (N*100 megs).

 I followed up by running enough instances of the test program that I
should have run out of memory free said I had, but the programs all
started, none were killed. I ran free again got a number pretty close
to what I thought should be free. It's a fun test to play with, I assume
results vary from kernel to kernel (how aggressive the kernel is
cleaning up returned ram).

Patrick