Re: Odd values for various memory metrics via SNMP

From: Garrett Wollman <wollman_at_bimajority.org>
Date: Wed, 27 Dec 2023 20:26:28 UTC
<<On Tue, 19 Dec 2023 20:16:38 +0100, "Patrick M. Hausen" <hausen@punkt.de> said:

> Now only "virtual memory" is left - according to the book that should be
> the sum of physical memory and swap space - and for my single Linux
> host it is.

> For the FreeBSD systems this is the one left that still looks nonsensical.

> OPNsense (8G RAM, 8G swap): 4.91 of 4.99G used.
> TrueNAS (64G RAM, 32G swap): 627 of 628G used.
> TrueNAS 2 (32G RAM, 32G swap): 512 of 516G used.

This is computed by the function vmtotal() in sys/vm/vm_meter.c.  It
walks all VM objects in the system, skipping those that are
unreferenced, and adds up all of their sizes.  There is one VM object
for every open file and every running executable, shared library, and
mmap()ed region, plus one for every copy-on-write mapping for each
process that has modified it, which includes the data segment of every
executable and shared library.  This has no connection to either
physical memory or swap space.

The "shared" statistics count only and exactly the underlying
(read-only) mapping of objects that are mapped with copy-on-write
semantics.

-GAWollman