Page size
![]() |
Page size refers the size of a memory block used by a processor architecture that supports paged memory. It also represents the smallest possible size of a memory allocation.
Page Size Tradeoff
Processor designers that implement paging often allow two or more, sometimes simultaneous, page sizes due to the global benefits or penalties of using a certain page size. There are several points that can factor into choosing the best page size.
Page Table Size
A system with a smaller page size uses more pages, requiring a page table that occupies more space. For example, if a 232 virtual address space is mapped to 4KB (212 bytes) pages, the number of virtual pages is 220 (20 = 32 - 12). However, if the page size is increased to 32KB (215 bytes), only 217 pages are required.
Internal Fragmentation
Rarely do processes require the use of an exact number of pages. As a result, the last page will likely only be partially full, wasting some amount of memory. Larger page sizes clearly increase the potential for wasted memory this way, as more potentially unused portions of memory are loaded into main memory. Smaller page sizes ensure a closer match to the actual amount of memory required in an allocation.
As an example, assume the page size is 1MB. If a process allocates 1025KB, two pages must be used, resulting in 1023KB of unused space.
Disk Access
When transferring from disk, much of the delay is caused by the seek time. Because of this, large, sequential transfers are more efficient than several smaller transfers. Transferring larger pages from disk to memory therefore, does not require much more time than smaller pages.
Determining the Page Size
Most operating systems allow programs to determine the page size at run time. This allows them to use memory more efficiently by aligning allocations to this size.
UNIX and POSIX-based Operating Systems
UNIX and POSIX-based systems use the C function sysconf().
#include <stdio.h> #include <unistd.h> // sysconf(3) int main() { printf("The page size for this system is %ld bytes\n", sysconf ok(_SC_PAGESIZE)); //_SC_PAGE_SIZE is OK too. return 0; }
Win32-based Operating Systems (Windows 9x, NT, ReactOS)
Win32-based operating system use the C function GetSystemInfo() function in kernel32.dll
#include <stdio.h> #include <windows.h> int main() { SYSTEM_INFO si; GetSystemInfo(&si); printf("The page size for this system is %u bytes\n", si.dwPageSize); return 0; }
References
Dandamudi, Sivarama P. (2003). Fundamentals of Computer Organization and Design. Springer. pp. 740–741. ISBN 038795211X.