# \[Metricbeat\] system/memory on macOS arm64: free and inactive memory under-reported 4× (page size hard-coded to 4 KiB)

**URL:** <https://discuss.elastic.co/t/metricbeat-system-memory-on-macos-arm64-free-and-inactive-memory-under-reported-4x-page-size-hard-coded-to-4-kib/391670>\
**Category:** Beats\
**Tags:** metricbeat\
**Created:** [November 17, 2026, 1:19pm UTC](https://discuss.elastic.co/t/metricbeat-system-memory-on-macos-arm64-free-and-inactive-memory-under-reported-4x-page-size-hard-coded-to-4-kib/391670 "2026-11-17T13:19:38Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![R\_V](https://avatars.discourse-cdn.com/v4/letter/r/7993a0/32.png) [@R\_V](https://discuss.elastic.co/u/R_V)\
**Post date:** [November 17, 2026, 1:19pm UTC](https://discuss.elastic.co/t/metricbeat-system-memory-on-macos-arm64-free-and-inactive-memory-under-reported-4x-page-size-hard-coded-to-4-kib/391670/1 "2026-11-17T13:19:38Z")

</div>

### Description

On Apple Silicon Macs, the `system.memory` metricset reports `system.memory.free`, `system.memory.actual.free` and the derived `used.pct` / `actual.used.pct` values that do not match the host. Idle machines show `system.memory.actual.used.pct` around 0.8–0.9, which triggers memory alerts.

We think we found the cause in `pkg/systemmetrics/metric/memory/memory_darwin.go`, which converts page counts to bytes with a fixed shift of 12 bits (4096-byte pages):

```go
kern := uint64(vmstat.inactive_count) << 12
free := uint64(vmstat.free_count) << 12

```

On Apple Silicon, `host_statistics(HOST_VM_INFO)` returns counts in kernel pages of **16384 bytes**. `sysctl hw.pagesize` returns `16384`, and `vm_stat` prints `(page size of 16384 bytes)`. As a result, `free` and `inactive` are 4× too small, and `used` / `actual.used` are too large.

Is this behaviour expected, or are we missing something in our setup?

### Example (24 GiB Mac mini, Apple Silicon, mostly idle)

`vm_stat` on the host:

```auto
Mach Virtual Memory Statistics: (page size of 16384 bytes)
Pages free: 119393.
Pages active: 524578.
Pages inactive: 521233.
Pages wired down: 164096.
Pages occupied by compressor: 204071.

```

| | metricbeat (pages × 4096) | pages × 16384 |
| --- | --- | --- |
| `system.memory.free` | 0.46 GiB | 1.82 GiB |
| inactive | 1.99 GiB | 7.95 GiB |
| `system.memory.used.pct` | 0.981 | 0.924 |
| `system.memory.actual.used.pct` | **0.898** | **0.593** |

`top` on the same host also reports far more unused memory than metricbeat's `free`. On our other Apple Silicon agents, the reported `actual.used.pct` is 0.79–0.87 while the hosts are idle; after correction it is 0.16–0.48. On Debian hosts, the values are consistent with `free -m`.

### Possible fix

Use the actual page size instead of the hard-coded shift, for example `vm_kernel_page_size`, `host_page_size()` or `sysctl hw.pagesize`.

- gopsutil fixed the same bug in [mem.VirtualMemory(): wrong page size on darwin arm64 by kyz · Pull Request #1334 · shirou/gopsutil · GitHub](https://github.com/shirou/gopsutil/pull/1334) ("wrong page size on darwin arm64").

### Versions

- Version: Metricbeat 8.19.x (darwin/arm64 build). The code on `main` is unchanged.
- Operating System: macOS 27 on Apple Silicon (M4)

### Steps to Reproduce

1. Run Metricbeat with the `system` module and the `memory` metricset on an Apple Silicon Mac.
2. Compare `system.memory.free` with `vm_stat` "Pages free" × `sysctl -n hw.pagesize`.
3. `system.memory.free` is 4× lower, and `system.memory.actual.used.pct` is much higher than Activity Monitor's memory usage.

### Configuration used:

```auto
metricbeat_version: 8.19.23

```

```yaml
- module: system
  period: 10s
  metricsets:
    - cpu
    - load
    - memory
  cpu.metrics: ["percentages", "normalized_percentages"]

```
