how to find the physical memory allocated to the kernel

Oliver Fromme olli at
Fri May 5 18:10:04 UTC 2006

Bharma Ji <bharmaji at> wrote:
 > Is there any way to determine the physical memory(not the virtual address
 > space) being allocated to the kernel at any instant? The overall problem is
 > that once I allocate say 512 MB to the kernel (virutal address space)
 > through the config file at compile time, I want to figure out how much of
 > that space is actually being used when the machine is under load.
 > Thanks for any answers

I'm not sure, but maybe you're looking for the difference
between kvm_size and kvm_free?

$ sysctl vm.kvm*
vm.kvm_size: 1065353216
vm.kvm_free: 809500672

So, in this case the kernel is actually using 244 MB of
its address space.

If you're interested in physical RAM, maybe you should
look at the difference between physmem and usermem:

$ sysctl hw.*mem
hw.physmem: 164016128
hw.usermem: 128507904

In this case the kernel is using about 34 MB of RAM.
(Both output above is from the same machine.)

Best regards

PS:  In case you're wondering, I'm using a sysctl wrapper
script that allows wildcards:

Oliver Fromme,  secnetix GmbH & Co. KG, Marktplatz 29, 85567 Grafing
Dienstleistungen mit Schwerpunkt FreeBSD:
Any opinions expressed in this message may be personal to the author
and may not necessarily reflect the opinions of secnetix in any way.

"C++ is to C as Lung Cancer is to Lung."
        -- Thomas Funke

More information about the freebsd-hackers mailing list