Re: where did all my memory go?

From: M. Warner Losh <imp_at_bsdimp.com>
Date: Wed, 16 Feb 2005 15:30:26 -0700 (MST)
In message: <1108588393.12275.9.camel_at_server.mcneil.com>
            Sean McNeil <sean_at_mcneil.com> writes:
: On Wed, 2005-02-16 at 14:57 -0600, Eric Anderson wrote:
: > Brooks Davis wrote:
: > > On Wed, Feb 16, 2005 at 12:12:10PM -0800, Sean McNeil wrote:
: > > 
: > >>With a system built yesterday on my amd64, I had plenty of memory
: > >>showing as free when the system completely started up.  Even after
: > >>intense usage I showed lots of free memory in top.  Over night at some
: > >>point all my memory is no longer free but inactive.  Is there anything
: > >>wrong here or is this expected behavior?  ps doesn't show any serious
: > >>usage by any particular process.  Also, if disk caches or something were
: > >>taking up the memory, I would expect it to have shown a lot earlier.
: > > 
: > > 
: > > On a system that has been up for any significant time, free memory
: > > should be very small since free memory is wasted.  My guess is that it
: > > is disk cache and that one of the nightly jobs accessed enough stuff to
: > > fill it.
: > 
: > Speaking of this - is there a way to flush the disk cache?  
: 
: I would have to dispute this fact.  Any disk cache should not be
: assigned to inactive user pages.  It should be, IMHO, cache or buffer
: memory.  In my original email, the vmstat -m output would support this:
: 
:   UFS dirhash  2656  1105K   1330K    15744  16,32,64,128,256,512,1024,2048
:    BIO buffer  5435 10870K  10940K   236537  2048
: 
: I see nothing on my system that comes close to accounting for the 1G of
: inactive memory.  Further, it really makes something like the system
: applet in gnome useless when all my memory is claimed to be allocated as
: user space.  I've only recently used this applet, but again I stress
: that after heavy usage of the system during initial boot I had plenty of
: ram shown as free.

vmstat -m only shows malloced memory.  The inactive memory are pages
that have been faulted into memory by the vm system and therefore
don't show up as malloced memory.  The text and data for your
processes don't show up in vmstat -m either.  Inactive memory just
means that 'You asked for it once, and on the off chance you'll ask
for it again, I'll keep it around rather than have this page of memory
go to waste.'  But the inactive pool is the first one to have pages
taken from it when other uses of the memory come up.

: As for flushing the disk cache, I thought that sync should do this.  It
: doesn't have any effect here, though.

Sync does flush the data to the disk.  It doesn't throw away all
memory that's currently used, just flushes the dirty pages to disk.

Really, there's nothing to worry about here.  FreeBSD is just using
the memory of the system to its fullest.  If it makes you feel better,
add 'inactive' and 'free' together to get a better feel for how much
memory is available.

Warner
Received on Wed Feb 16 2005 - 21:31:14 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:38:28 UTC