---
name: "sg_get_page_stats"
section: "3"
platform: "linux"
package: "libstatgrab"
version: "0.92.1-2"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/sg_get_page_stats"
---

# sg\_get\_page\_stats(3)

get paging statistics

## NAME

sg\_get\_page\_stats, sg\_get\_page\_stats\_r, sg\_get\_page\_stats\_diff, sg\_get\_page\_stats\_diff\_between, sg\_free\_page\_stats - get paging statistics

## SYNOPSIS

```
FC#include <statgrab.h>F[0]
```

FCsg\_page\_stats \***sg\_get\_page\_stats**F\[0\]  FC(size\_t \**entries*);F\[0\]

FCsg\_page\_stats \***sg\_get\_page\_stats\_r**F\[0\]  FC(size\_t \**entries*);F\[0\]

FCsg\_page\_stats \***sg\_get\_page\_stats\_diff**F\[0\]  FC(size\_t \**entries*);F\[0\]

FCsg\_page\_stats \***sg\_get\_page\_stats\_diff\_between**F\[0\]  FC(const sg\_page\_stats \**cur*, const sg\_page\_stats \**last*, size\_t \**entries*);F\[0\]

FCsg\_error **sg\_free\_page\_stats**F\[0\]  FC(sg\_page\_stats \**data*);F\[0\]

## DESCRIPTION

The page stats module deliver the number of pages swapped in and out, either since the machine has been booted (by the FC**sg\_get\_page\_stats**F\[0\]() and FC**sg\_get\_page\_stats\_r**F\[0\]() functions) or the difference between two measured statistics (by the FC**sg\_get\_page\_stats\_diff**F\[0\]() and FC**sg\_get\_page\_stats\_diff\_between**F\[0\]() functions).

The FC**sg\_get\_page\_stats\_diff**F\[0\]() function calculates the difference between the last call to the function FC**sg\_get\_page\_stats**F\[0\]() in this thread (the statistics of the earlier call are saved and FC**sg\_get\_page\_stats**F\[0\]() is called immediately after this).

**API Shortcut**

| | | |
| --- | --- | --- |
| function | returns | data owner |
| sg\_get\_page\_stats | FCsg\_page\_statsF\[0\] \* | libstatgrab (thread local) |
| sg\_get\_page\_stats\_r | FCsg\_page\_statsF\[0\] \* | caller |
| sg\_get\_page\_stats\_diff | FCsg\_page\_statsF\[0\] \* | libstatgrab (thread local) |
| sg\_get\_page\_stats\_diff\_between | FCsg\_page\_statsF\[0\] \* | caller |

The FCsg\_page\_statsF\[0\] buffer received from FC**sg\_get\_page\_stats\_r**F\[0\]() and the FC**sg\_get\_page\_stats\_diff\_between**F\[0\]() must be freed using FC**sg\_free\_page\_stats**F\[0\]() when not needed any more. The caller is responsible for doing it.

## RETURN VALUES

```
FC
typedef struct{
        unsigned long long pages_pagein;
        unsigned long long pages_pageout;
        time_t systime;
}sg_page_stats;
    F[0]
```

- FCpages\_pageinF\[0\]

  The number of pages swapped into memory.

- FCpages\_pageoutF\[0\]

  The number of pages swapped out of memory (to swap).

- FCsystimeF\[0\]

  The timestamp when the above stats where collected in seconds since epoch or the time period over which FCpages\_pageinF\[0\] and FCpages\_pageoutF\[0\] were transferred.

## BUGS

Solaris doesn't seem to report accurately. It reports the number of pages swapped into memory, not necessarily from swap. This feature isn't deemed entirely reliable.

## SEE ALSO

[**statgrab**(3)](/statgrab/3.md)

## WEBSITE

⟨https://libstatgrab.org/⟩
