# what sysctl entry shows the amount of RAM used for disk buffers?



## ekingston (Nov 2, 2018)

Hi all, according to an article I read a while ago (but can't find now), FreeBSD memory is divided up into

Active - memory used by applications.
Inactive - memory that has been but still has data in it.
Wired - memory used by the kernel that cannot be swapped out.
Cache - memory used to cache data for applications.
Buffers - memory used as a disk cache.
Free - memory that is free to be used.
I dug through sysctl and found values for all of those except Buffers. Is there a sysctl value I can check for Buffers?

I want this because I've been fiddling with RRDTool and have a small VM that is nicely graphing memory usage for me except for the buffers value.


----------



## yuripv (Nov 2, 2018)

/usr/src/usr.bin/top/machine.c is a nice way to know where top(1) gets its values from.  So, apparently, it's vfs.bufspace, but that seems to be always 0 on my systems using ZFS, so if you do that as well, you might want to use ARC related stats as well.


```
GETSYSCTL("vfs.bufspace", bufspace);
                GETSYSCTL("vm.stats.vm.v_active_count", memory_stats[0]);
                GETSYSCTL("vm.stats.vm.v_inactive_count", memory_stats[1]);
                GETSYSCTL("vm.stats.vm.v_laundry_count", memory_stats[2]);
                GETSYSCTL("vm.stats.vm.v_wire_count", memory_stats[3]);
                GETSYSCTL("vm.stats.vm.v_free_count", memory_stats[5]);
                GETSYSCTL("vm.stats.vm.v_swappgsin", nspgsin);
                GETSYSCTL("vm.stats.vm.v_swappgsout", nspgsout);
```


----------

