On Wed, 26 Jul 2006, Stephane Dupille wrote:
> I have a computer running FreeBSD 6.1.
>
> As time passing by, the memory fills up. When the machine starts, memory
is
> occupied to 30 %, and after two or three weeks memory is occupied to 100 %
> and it begins to use swap.
>
> It is "inactive" pages that fills up the memory.
>
> I tried to restart every process, but memory usage does not decrease. Only
> a reboot can fix that. And I'm not able to see which process leaks.
>
> I was not able to find a correct definition of what "inactive"
memory is.
> First, I would like to know what are these kind of pages : wired, active,
> inactive, cache and free.
>
> Is that normal that inactive memory usage grows ? What should I do ?
>
> Do you have any tools to monitor memory usage of processes ?
You can find an article discussing some of the FreeBSD VM system design here:
http://www.freebsd.org/doc/en_US.ISO8859-1/articles/vm-design/article.html
This document is gradually aging, and doesn't cover certain elements of the
design, including some recent optimizations, SMP behavior, etc, but still
makes quite a good read.
It could be that you have applications leaking memory, but it's more likely
that the VM system is simply being efficient. Free memory is, in effect,
wasted memory, since it's not being used. FreeBSD will agressively cache
file
system data, and either drop or page out unused pages (depending on whether
they are dirty) in order to maximize the amount of memory available for
actively used data. This means it will swap out dirty pages allocated by a
process if the process isn't using them, rather than keep them in memory
preventing that memory from being used by processes that need it. The result
is that at any given moment, an active system should have almost no free
memory, and instead should be providing as much memory as possible to active
pages, and the largest possible file system cache. This may seem
counter-intuitive compared to some other systems where a premium is placed on
free pages as representing the resources available to run additional
applications. We consider memory floating around "unused" to be a
waste of
memory that could be used to improve system performance.
"systat -vmstat 1" is a good tool to monitor the VM system, as it will
let you
monitor memory use, in particular, the vnode and swap paging rates. You can
use ps(1) with various parameters to inspect process memory use. A popular
combination is "aux", which views all processes and displays, among
other
things, their virtual and resident sizes. The resident size is the figure you
want to look at, as it represents the number of pages actually in memory,
rather than pages that could be paged in.
Robert N M Watson
Computer Laboratory
University of Cambridge