Cache Memory in top command
Michel Talon
talon at lpthe.jussieu.fr
Thu Oct 7 12:40:24 UTC 2010
Bruce Cran said:
> The top(1) man page is clearly in error, at least on FreeBSD systems.
Here is an answer to a similar question given by John Dyson the author
of the FreeBSD VM system.
http://groups.google.fr/group/comp.unix.bsd.freebsd.misc/browse_thread/thread/7d3d28b807640847/9c081931470adefb?hl=fr&q=jdyson+ctive,+Inact,+Wired,+Cache,+Buf#9c081931470adefb
Lowell Gilbert wrote:
> "Nospam" <nos... at no-nonsense.org> writes:
> > Here you see what I get to see when I use top (ofcourse it's at one
> > certain
> > time...). Why is there so much Inactive memory? Why isn't that
> > memory Free?
> > Is this correct, or is there some bad application?
> It's correct. There's a slogan that goes "free memory is wasted
> memory." Alternatively, you could look at "inactive" memory as being
> free if that makes you happier.
The memory stats are gathered, and a semi-layered state of the memory
pages are presented. Inactive memory is quickly reusable, but is deemed
to be statistically inactive. The wasted memory in the system is indeed
the memory marked 'free.' Most of the other memory is used for other (caching)
purposes.
If you look at the latest version of 'top', Active, Inact, Wired and
Cache memory are all memory that contain mostly usable data. Buf is
sort of a subset of Wired, and Free is totally disused. Active memory
is mapped into processes, Inact memory might be mapped into processes,
and might be staged for being paged out. Wired memory is mapped into
the kernel, and Cache memory is unmapped but still retains potentially
interesting data. When a system is moderately heavily used, the Free
memory is actually kept small in amount, and is indeed the 'wasted'
memory in the system.
One time, I wrote some code that estimated the 'free' memory in the
system, and it isn't really very intuitive. Since FreeBSD has VM memory
management, the amount of free real memory is tricky to calculate. The
best thing to believe (if you can depend on paging), is that the system
will try to maintain a proper balance of memory usage.
And elsewhere he says:
Cache are the pages that are available for quick reuse. Inact and
Active are part of the staging algorithm, where Inact is use as a 2nd
chance and staging for cleaning (writing changed data.) Free are also
pages that are available for quick reuse, but have no data, and are
available at interrupt time.
The stats scheme includes some stats associatiated with active pages
also.
--
Michel TALON
More information about the freebsd-questions
mailing list