Determining free memory on FreeBSD 4.8-REL

Erik Trulsson ertr1013 at student.uu.se
Fri Feb 13 13:57:06 PST 2004


On Fri, Feb 13, 2004 at 03:28:34PM -0600, dap wrote:
> I know this question has been asked, but the answers I find tend to be along
> the lines of "Well, it's complicated."

It *is* a bit complicated, in part because it depends on how you define "free
memory".

> 
> 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:
> 
> last pid: 23737;  load averages:  0.21,  0.15,  0.27  up 5+20:43:14
> 15:22:31
> 231 processes: 1 running, 230 sleeping
> CPU states:  5.0% user,  0.0% nice,  2.7% system,  1.6% interrupt, 90.7%
> idle
> Mem: 76M Active, 25M Inact, 62M Wired, 2876K Cache, 35M Buf, 82M Free
> Swap: 496M Total, 41M Used, 456M Free, 8% Inuse
> 
> 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.)

> 
> Why am I using 41MB of swap then if I have 82MB of free memory?

One possible reason is that you previously used a lot of memory and so
that memory was swapped out, but it has not been swapped in again since
it has been referenced since then.

The other reason is that FreeBSD starts swapping before it absolutely
has to, in order to always have a some free memory available when a
program wants it.

If you want a detailed description on how the memory system works you
could try reading
http://www.freebsd.org/doc/en_US.ISO8859-1/articles/vm-design/index.html


> 
> On another box I have:
> 
> last pid: 42029;  load averages:  0.46,  0.38,  0.34   up 5+20:24:15
> 15:27:12
> 35 processes:  2 running, 33 sleeping
> CPU states:  1.0% user,  0.0% nice, 11.7% system,  6.1% interrupt, 81.3%
> idle
> Mem: 51M Active, 332M Inact, 97M Wired, 19M Cache, 61M Buf, 992K Free
> Swap: 1008M Total, 116K Used, 1008M Free
> 
> 992K in Free but 332MB in Inact. So what is my conclusion here? That I have
> 332,992 KB free for use?

You have about 332M + 19M + 992K = about 352M of reasonably free
memory.  

> 
> Looking at vmstat I have no swapping going on:
> 
> # vmstat 5
>  procs      memory      page                    disks     faults      cpu
>  r b w     avm    fre  flt  re  pi  po  fr  sr ad0 ad4   in   sy  cs us sy
> id
>  3 0 0  189844  29624   80   0   0   0 442 375   0   0 2863 4011 564  3  6
> 90 (ignore)
>  2 0 0  188480  27132    2   0   0   0 829 714   0   0 5244 1041 667  1  9
> 90
>  2 0 0  188900  16660    1   0   0   0 1231 710   0   3 7215 1425 809  1 10
> 89
> 
> 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.


-- 
<Insert your favourite quote here.>
Erik Trulsson
ertr1013 at student.uu.se


More information about the freebsd-questions mailing list