I have a bit of an interesting conundrum with writing the memory plugin for NetB...
Buckwheat :haskell: 🦀 :freebsd: :openbsd: :netbsd: @buckwheat@neondystopia.world
I have a bit of an interesting conundrum with writing the memory plugin for NetBSD...
now I've worked with NetBSD's lower-level interfaces for grabbing memory info before, it's a little weird because you get the total amount of memory from sysctl and store it within a variable of type
memory is a bit more mysterious with NetBSD (and also FreeBSD) in contrast to Linux, a lot of people get spooked that FreeBSD and NetBSD will show a significant amount of memory in active usage. a lot of the tools we use are designed for the way Linux handles memory, and FreeBSD/NetBSD both have this quirk of caching quite a bit of memory for usage later. that does reduce the "free" memory, but that doesn't mean that memory is actually in use, it just means memory is being kept close to the CPU to reduce processing time and makes data access by the CPU faster. ask any BSD nerd, and they'll tell you that free memory is wasted memory, because BSDs tend to use memory this way.
now, if you check
now I've worked with NetBSD's lower-level interfaces for grabbing memory info before, it's a little weird because you get the total amount of memory from sysctl and store it within a variable of type
int64_t using hw.usermem64, which gives you the output in bytes. however, if you want to query the active memory, you still use sysctl but you store it in a struct vmtotal using vm.vmmeter. this struct would also be used for getting the amount of free memory. however, pretty much every other value you can get from vm.vmmeter is downright useless. that's not all though.memory is a bit more mysterious with NetBSD (and also FreeBSD) in contrast to Linux, a lot of people get spooked that FreeBSD and NetBSD will show a significant amount of memory in active usage. a lot of the tools we use are designed for the way Linux handles memory, and FreeBSD/NetBSD both have this quirk of caching quite a bit of memory for usage later. that does reduce the "free" memory, but that doesn't mean that memory is actually in use, it just means memory is being kept close to the CPU to reduce processing time and makes data access by the CPU faster. ask any BSD nerd, and they'll tell you that free memory is wasted memory, because BSDs tend to use memory this way.
now, if you check
/proc/meminfo, which naively we like to do on Linux for the memory statistics; buffer memory is going to always be equal to the free memory in NetBSD. why? I'm not quite sure yet, that I still need to read about, so I don't know how I'll handle buffered memory. that just means I need to figure out a sane way to get the cached memory, as vm.vmmeter type doesn't provide that information to me... I've checked the vmstat source code before for that help but, that didn't really give me any insightful information. fingers crossed I solved this.