Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 14 Dec 2003 17:04:55 +0100
From:      Benjamin Lutz <benlutz@datacomm.ch>
To:        freebsd-questions@freebsd.org
Subject:   memory categories
Message-ID:  <20031214170455.723380b9.benlutz@datacomm.ch>

next in thread | raw e-mail | index | archive | help
--Signature=_Sun__14_Dec_2003_17_04_55_+0100_qxsinayh1K6SmnKN
Content-Type: text/plain; charset=US-ASCII
Content-Disposition: inline
Content-Transfer-Encoding: 7bit

I'm trying to understand what FreeBSD uses its memory for.
Unfortunately, I've not been able to find documentation that answers all
my questions, so I'm hoping someone on this list can answer them.

Let's start with top(1)'s memory categories:

Free: Not used for any purpose. (vm.stats.vm.v_free_count)

Active: Used by userland programs. (vm.stats.vm.v_active_count)

Cache: Well, this obviously caches something... but what? Filesystem?
(vm.stats.vm.v_cache_count)

Inactive: This seems to be the biggest chunk of memory on my system.
What exactly is the meaning of this? Someone explained it as "memory
that a program has grabbed that isn't currently being used. It can be
swapped to disk if RAM is needed by other programs.". How does the
system know that this memory is not being used? Is this the difference
between the RES and SIZE colums in top(1)'s output?
(vm.stats.vm.v_inactive_count)

Wired: I've only been able to figure out that this is memory that's
being actively used and that cannot be relocated in any way. Could
someone explain this in a bit more detail? What exactly is the
difference between active and wired memory? (vm.stats.vm.v_wired_count)

Buf: I'm puzzled... If I add up Free, Active, Cache, Inactive, Wired and
Buf, I get more memory than I have physically installed. I could not
find a sysctl that represents this value. Also, .v_free_count,
v_active_count, v_cache_count, v_inactive_count and v_wired_count add up
to vm.stats.vm.v_page_count... where does this Buf come from?

And some more questions: On my system, these sysctls have these values:
hw.physmem = 1064734720 = 1015.410MB
hw.usermem: 947351552 = 903.465MB
hw.availpages = 259945
vm.stats.vm.v_page_count: 255299
vm.stats.vm.v_page_size: 4096
hw.availpages * .v_page_size = 1064734720 = 1015.410MB
.v_page_count * .v_page_size = 1045704704 = 997.262MB

I have 1024MB of RAM installed. Why is hw.physmem inaccurate? And why
is .v_page_count * .v_page_size less than hw.physmem? Is the difference
between hw.physmem and hw.usermem used for the kernel? If yes, 112MB
seems to be a huge amount?

Phew... quite a few questions... Let's see what answers you can give me!

Benjamin

--Signature=_Sun__14_Dec_2003_17_04_55_+0100_qxsinayh1K6SmnKN
Content-Type: application/pgp-signature

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.3 (FreeBSD)

iD8DBQE/3IosgShs4qbRdeQRAibGAJ9G7FjwK75KQNg69b/9Xdiv2wFlzgCdGFe0
NJuouASibNIQmgUuFmHae5Q=
=sqO2
-----END PGP SIGNATURE-----

--Signature=_Sun__14_Dec_2003_17_04_55_+0100_qxsinayh1K6SmnKN--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20031214170455.723380b9.benlutz>