package kaun-board

  1. Overview
  2. Docs

Module Sysstat.MemSource

Memory statistics (instantaneous).

Sourcetype t = {
  1. total : int64;
    (*

    Total physical memory.

    *)
  2. used : int64;
    (*

    Memory in use (calculated via platform-specific formula).

    *)
  3. free : int64;
    (*

    Free memory available for allocation.

    *)
  4. available : int64;
    (*

    Memory available for starting new applications without swapping.

    On macOS, approximated as free + inactive + purgeable.

    *)
  5. compressed : int64;
    (*

    Compressed memory (macOS only, 0L on Linux).

    *)
  6. wired : int64;
    (*

    Wired (non-pageable) memory (macOS only, 0L on Linux).

    *)
  7. active : int64;
    (*

    Active memory pages (macOS only, 0L on Linux).

    *)
  8. inactive : int64;
    (*

    Inactive memory pages (Linux: cached + sreclaimable - shmem).

    *)
  9. purgeable : int64;
    (*

    Purgeable memory (macOS) or buffers (Linux).

    *)
  10. speculative : int64;
    (*

    Speculative memory (macOS only, 0L on Linux).

    *)
  11. external_ : int64;
    (*

    External memory (macOS only, 0L on Linux).

    *)
  12. page_size : int64;
    (*

    System page size in bytes.

    *)
  13. swap_total : int64;
    (*

    Total swap space.

    *)
  14. swap_used : int64;
    (*

    Used swap space.

    *)
}

Memory usage statistics.

All size fields are in bytes. Memory statistics are instantaneous snapshots, not cumulative counters.

Platform behavior:

  • Linux: The used field is computed as total - free - buffers - (cached + sreclaimable - shmem).
  • macOS: The used field is computed as active + inactive + speculative + wired + compressed - purgeable - external, with compressed subtracted from the display value.
Sourceval sample : unit -> t

sample () returns current memory usage statistics.

  • raises Sys_error

    if memory statistics are unavailable on the current platform or an error occurs during sampling.