# How to print out explicitly the memory footprint of the kernel



## Alain De Vos (Apr 16, 2020)

How to find out how much physical memory is used by the kernel  and its buffers ?
Currently I have 4.7G wired memory with around 0.7G resident memory used by zfs-arc and around 1.2G used by xorg and around 1.2G used by firefox.
I wonder where the rest is gone.
I found : vm.kmem_map_size: 3100921856
Maybe this is a bit large.


----------



## George (Apr 16, 2020)

This? `kldstat -h`


----------



## Alain De Vos (Apr 16, 2020)

Interesting, `kldstat -hvd | grep M` returns,

```
1  254 0xffffffff80200000   22M kernel (/boot/kernel/kernel)
8    1 0xffffffff81e53000  1.3M radeonkms.ko (/boot/modules/radeonkms.ko)
19    1 0xffffffff82064000  201K radeon_SUMO_uvd_bin.ko (/boot/modules/radeon_SUMO_uvd_bin.ko)
        336 radeon_SUMO_uvd_bin_fw (0, 0, 0x0)
69    1 0xffffffff8223b000  2.3M zfs.ko (/boot/kernel/zfs.ko)
82    1 0xffffffff824eb000  5.2M vmm.ko (/boot/kernel/vmm.ko)
```
These are not spectacular sizes. But after tuning the parameters a bit, sysctl vm.kmem_map_size returns 630398976


----------



## PMc (Apr 16, 2020)

I think you can consider it a pain to figure that out in detail.
Usually ARC < kmem_map_size < wired.
Then, the actual use can somehow be collected from `vmstat -m` and `vmstat -z`.
What kldstat reports, seem to be the code-segment sizes only.


----------



## Alain De Vos (Apr 16, 2020)

`vmstat -m | grep M` returns

```
UMAHash    Memuse 1572K
vmstat -z
UMA Slabs Used 92282
VM OBJECT Used 91755
MAP ENTRY Used 43598
```


----------

