Connaitre le page size de sa machine

From / Bloc Notes Informatique
Jump to: navigation, search

1 Determining the Page Size

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

1.1 UNIX and POSIX-based Operating Systems

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

Edit a test.c file and paste it :

#include <stdio.h>     // printf(3)
#include <unistd.h>    // sysconf(3)
        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

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

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

#include <windows.h>
printf("The page size for this system is %u bytes\n", si.dwPageSize);