Determining free memory on FreeBSD 4.8-REL
Uwe Doering
gemini at geminix.org
Fri Feb 13 15:38:12 PST 2004
Erik Trulsson wrote:
> On Fri, Feb 13, 2004 at 03:28:34PM -0600, dap wrote:
>>How do I determine if my FreeBSD is actually low on memory not? And what is
>>Inact? I did read the manpages, but even they seem to skirt how I should
>>view Inact vs. Free. (I did read the tuning manpage.)
>>
>>Let's say I have this:
>>[...]
>>
>>So I have 82MB of free memory, 35MB of memory being used by the OS as disk
>>IO, cache is different from Buf in some way or another (the top manpage
>>doesn't quite go into details here). I don't quite get Inact and Wired.
>
> You can view all of Inactive, Cache and Free as free memory. The
> difference is if the memory might be "dirty" and need to be flushed to
> swap before being reused. (Free is completely free and ready to be used
> at once, Cache is probably not dirty, while Inactive is probably
> dirty.)
Let me rephrase this a little. Pages in Inactive _can_ be dirty (if
they have been written to) while pages in Cache are already clean
(laundered), that is, can be used for other purposes without delay, but
can also be reactivated (moved to Active) if their current contents is
needed again. Inactive, on the other hand, has to be laundered before
the pages move on to Cache, which they eventually do.
It works like this: If the kernel's laundry routine finds a dirty page
in Inactive for the first time it marks and skips it, in the hopes that
the page is ephemeral and will be gone next time around. If it's not
gone and the launderer finds it for the second time it schedules it for
flushing to disk and skips it again. If it later finds the page for the
third time it is hopefully clean by then and can be moved to Cache.
Pages that are clean right from the start (that only have been read)
will be moved to Cache without further ado, whenever (Cache+Free) falls
below its lower hysteresis level. That is, the move will be in chunks.
And yes, I agree that it's a little complicated. ;-)
>>If I see ANY swapping going on should I worry? I don't think so. Some
>>swapping is normal in UNIX in general.
>
> As you note a little bit of swapping is perfectly normal.
> If you start to see a lot of swapping you probably want more memory.
The slow increase in swapped-out pages you see over time even if the
system is not short of memory is caused by the laundry procedure I
described above, and is perfectly normal. It's kind of a preemptive
strategy in order to have enough clean pages available without delay
when you need them.
Hope to have shed some light on the subject.
Uwe
--
Uwe Doering | EscapeBox - Managed On-Demand UNIX Servers
gemini at geminix.org | http://www.escapebox.net
More information about the freebsd-questions
mailing list