In this section you will learn how to get overall memory information (usage by OS) and memory module layout:
For function reference and examples we assume, that we imported systeminformation as follows:
const si = require('systeminformation');
System Memory and Memory Layout
All functions in this section return a promise or can be called with a callback function (parameter cb in the function reference)
| Function | Result object | Linux | BSD | Mac | Win | Sun | Comments |
|---|---|---|---|---|---|---|---|
| si.mem(cb) | { ...} | X | X | X | X | Memory information (object) | |
| total | X | X | X | X | total memory in bytes | ||
| free | X | X | X | X | not used in bytes | ||
| used | X | X | X | X | used (incl. buffers/cache) | ||
| active | X | X | X | X | used actively (excl. buffers/cache and reclaimable ZFS ARC, see notes) | ||
| buffcache | X | X | X | used by buffers+cache | |||
| buffers | X | used by buffers | |||||
| cached | X | used by cache | |||||
| slab | X | used by slab | |||||
| available | X | X | X | X | potentially available (total - active, see notes) | ||
| swaptotal | X | X | X | X | |||
| swapused | X | X | X | X | |||
| swapfree | X | X | X | X | |||
Example
{
total: 67092135936,
free: 65769291776,
used: 1322844160,
active: 1032495104,
available: 66059640832,
buffers: 63213568,
cached: 800124928,
slab: 268804096,
buffcache: 1132142592,
swaptotal: 8589930496,
swapused: 0,
swapfree: 8589930496
}
|
|||||||
| si.memLayout(cb) | [ { ...}] | X | X | X | X | Memory Layout (array of objects) | |
| [0].size | X | X | X | X | size in bytes | ||
| [0].bank | X | X | X | memory bank | |||
| [0].type | X | X | X | X | memory type | ||
| [0].ecc | X | X | X | X | ECC memory | ||
| [0].clockSpeed | X | X | X | X | clock speed | ||
| [0].formFactor | X | X | X | form factor | |||
| [0].manufacturer | X | X | X | X | manufacturer | ||
| [0].partNum | X | X | X | X | part number | ||
| [0].serialNum | X | X | X | X | serial number | ||
| [0].voltageConfigured | X | X | X | voltage conf. | |||
| [0].voltageMin | X | X | X | voltage min | |||
| [0].voltageMax | X | X | X | voltage max | |||
Example
[
{
size: 34359738368,
bank: 'BANK 0',
type: 'DDR4',
ecc: false,
clockSpeed: 2667,
formFactor: 'SODIMM',
manufacturer: '029E',
partNum: 'CMSX64.....',
serialNum: '00000000',
voltageConfigured: 1.2,
voltageMin: 1.2,
voltageMax: 1.2
},
{
size: 34359738368,
bank: 'BANK 2',
type: 'DDR4',
ecc: false,
clockSpeed: 2667,
formFactor: 'SODIMM',
manufacturer: '029E',
partNum: 'CMSX64.....',
serialNum: '00000000',
voltageConfigured: 1.2,
voltageMin: 1.2,
voltageMax: 1.2
}
]
|
|||||||
ZFS ARC and the active / available values
mem().active is meant to be the memory that is really in use - everything that would be handed back to your processes under pressure is subtracted and shows up in available instead. For the ordinary page cache the operating system does that bookkeeping itself. ZFS does not take part in it: its cache, the ARC (Adaptive Replacement Cache), lives outside the page cache, so Linux reports it in neither Cached nor MemAvailable, and FreeBSD counts it as wired memory.
Because the ARC grows until it has taken roughly half of the machine, that made active sit near total permanently on a ZFS host - and worse, it hid real memory growth, since the ARC gives memory back at exactly the same rate until there is nothing left to give.
The ARC never shrinks below c_min, so everything it holds above that value is treated as available. The correction is read from /proc/spl/kstat/zfs/arcstats on Linux and from kstat.zfs.misc.arcstats on FreeBSD - no root privileges and no arc_summary / arcstat binary required. Without ZFS nothing changes. This is the same correction htop applies.
available can therefore be larger than free + buffcache and larger than what free -b reports - free has no ZFS awareness. The other values (used, buffers, cached, slab, buffcache) stay exactly as the operating system reports them.