How to Estimate the Kernel Size in Memory

Hi everyone,


I’m trying to figure out how to measure the memory usage of the kernel at runtime. Specifically, I’d like to know how to get detailed statistics such as:
  • total memory used by the kernel
  • heap memory
  • stack memory
  • physical memory
  • swapped memory
  • mapped memory
  • resident memory
Is there a standard way or set of tools to obtain this information? Any pointers or examples would be really helpful.

Thanks in advance!
 
Hey, welcome to the FreeBSD forums.​
I’m trying to figure out how to measure the memory usage of the kernel at runtime. […]
Have a look at Thread 84787. Apparently you can get some stats(7) via sysctl(8).​
Bash:
sysctl -d hw.realmem kern.kstack_pages vm.kmem_map_size vm.kmem_size
hw.realmem: Amount of memory (in bytes) reported by the firmware
kern.kstack_pages: Kernel stack size in pages
vm.kmem_map_size: Current kmem allocation size
vm.kmem_size: Size of kernel memory
Programmatically you can use libmemstat(3).​
  • swapped memory
Kernel memory is not swapped. It would be detrimental to, yeah, everything.​
  • resident memory
Define resident. Once the loader(8) loaded it, the kernel file itself stays resident, duh! There’s probably more.​
Is there a standard way or set of tools to obtain this information?
Nope, it’s all FreeBSD‐specific.​
 
Back
Top