Skip to content

How to Check the Page Size of Your Machine

Determining the Page Size

Most operating systems allow programs to determine what the page size is so that they can allocate memory more efficiently.

UNIX and POSIX-based Operating Systems

UNIX and POSIX-based systems use the C function sysconf().

Edit a test.c file and paste it:

1
2
3
4
5
6
7
8
9
#include <stdio.h>     // printf(3)
#include <unistd.h>    // sysconf(3)

int
main(void)
{
        printf("The page size for this system is %ld bytes\n", sysconf(_SC_PAGESIZE)); //_SC_PAGE_SIZE is OK too.
        return 0;
}

Then compile it with gcc:

gcc -o test test.c

Now launch it:

# ./test
The page size for this system is 4096 bytes

Win32-based Operating Systems (Windows 9x, NT, ReactOS)

Win32-based operating system use the C function GetSystemInfo() function in kernel32.dll

1
2
3
4
5
6
#include <windows.h>

SYSTEM_INFO si;

GetSystemInfo(&si);
printf("The page size for this system is %u bytes\n", si.dwPageSize);