A page, memory page, or virtual page is a fixed-length contiguous block of
virtual memory
In computing, virtual memory, or virtual storage is a Memory management (operating systems), memory management technique that provides an "idealized abstraction of the storage resources that are actually available on a given machine" which "cre ...

, described by a single entry in the
page table
A page table is the data structure
Image:Hash table 3 1 1 0 1 0 0 SP.svg, 315px, A data structure known as a hash table.
In computer science, a data structure is a data organization, management, and storage format that enables efficient access ...
. It is the smallest unit of data for memory management in a virtual memory
operating system
An operating system (OS) is system software
System software is software designed to provide a platform for other software. Examples of system software include operating systems (OS) like macOS, Linux, Android (operating system), Android and Mi ...

. Similarly, a page frame is the smallest fixed-length contiguous block of
physical memory
File:Maxell DVD-RW 4.7GB crop 20051120.jpg, A spindle of DVD-RW's.
Computer data storage is a technology consisting of computer components and Data storage device, recording media that are used to retain digital data (computing), data. It is ...
into which memory pages are mapped by the operating system.
A transfer of pages between main memory and an auxiliary store, such as a
hard disk drive
A hard disk drive (HDD), hard disk, hard drive, or fixed disk is an electro-mechanical data storage device
On a reel-to-reel tape recorder (Sony TC-630), the recorder is data storage equipment and the magnetic tape is a data stora ...

, is referred to as
paging
In computer
A computer is a machine that can be programmed to carry out sequences of arithmetic or logical operations automatically. Modern computers can perform generic sets of operations known as Computer program, programs. These prog ...

or swapping.
Page size trade-off
Page size is usually determined by the processor architecture. Traditionally, pages in a system had uniform size, such as 4,096
byte
The byte is a unit of digital information that most commonly consists of eight bit
The bit is a basic unit of information in computing
Computing is any goal-oriented activity requiring, benefiting from, or creating computing machinery. It ...
s. However, processor designs often allow two or more, sometimes simultaneous, page sizes due to its benefits. 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
A page table is the data structure
Image:Hash table 3 1 1 0 1 0 0 SP.svg, 315px, A data structure known as a hash table.
In computer science, a data structure is a data organization, management, and storage format that enables efficient access ...
that occupies more space. For example, if a 2
32 virtual address space is mapped to 4
KiB
The byte is a unit of digital information that most commonly consists of eight bit
The bit is a basic unit of information in computing
Computing is any goal-oriented activity requiring, benefiting from, or creating computing machinery. It ...
(2
12 bytes) pages, the number of virtual pages is 2
20 = (2
32 / 2
12). However, if the page size is increased to 32 KiB (2
15 bytes), only 2
17 pages are required. A multi-level paging algorithm can decrease the memory cost of allocating a large page table for each process by further dividing the page table up into smaller tables, effectively paging the page table.
TLB usage
Since every access to memory must be mapped from virtual to physical address, reading the page table every time can be quite costly. Therefore, a very fast kind of cache, the
translation lookaside buffer
A translation lookaside buffer (TLB) is a memory cache
Cache, caching, or caché may refer to:
Places
* Cache (Aosta), a frazione in Italy
* Cache Creek (disambiguation), several places
United States
* Cache, Idaho, an unincorporated communit ...

(TLB), is often used. The TLB is of limited size, and when it cannot satisfy a given request (a ''TLB miss'') the page tables must be searched manually (either in hardware or software, depending on the architecture) for the correct mapping. Larger page sizes mean that a TLB cache of the same size can keep track of larger amounts of memory, which avoids the costly TLB misses.
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 lead to large amount of wasted memory, 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 1024 KiB. If a process allocates 1025 KiB, two pages must be used, resulting in 1023 KiB of unused space (where one page fully consumes 1024 KiB and the other only 1 KiB).
Disk access
When transferring from a rotational disk, much of the delay is caused by seek time, the time it takes to correctly position the read/write heads above the disk platters. Because of this, large sequential transfers are more efficient than several smaller transfers. Transferring the same amount of data from disk to memory often requires less time with larger pages than with smaller pages.
Getting page size programmatically
Most operating systems allow programs to discover the page size at
runtime. This allows programs to use memory more efficiently by aligning allocations to this size and reducing overall internal fragmentation of pages.
Unix and POSIX-based operating systems
Unix
Unix (; trademarked as UNIX) is a family of multitasking, multiuser
Multi-user software is computer software
Software is a collection of Instruction (computer science), instructions that tell a computer how to work. This is in contrast t ...

and
POSIX
The Portable Operating System Interface (POSIX) is a family of standard
Standard may refer to:
Flags
* Colours, standards and guidons
* Standard (flag), a type of flag used for personal identification
Norm, convention or requirement
* Sta ...
-based systems may use the system function
sysconf()
, as illustrated in the following example written in
the C programming language
''The C Programming Language'' (sometimes termed ''K&R'', after its authors' initials) is a computer programming
Computer programming is the process of designing and building an executable computer program to accomplish a specific computing r ...
.
#include
#include /* sysconf(3) */
int main(void)
In many Unix systems, the command-line utility
getconf
can be used.
For example,
getconf PAGESIZE
will return the page size in bytes.
Windows-based operating systems
Win32
The Windows API, informally WinAPI, is Microsoft's core set of application programming interface
In computing
Computing is any goal-oriented activity requiring, benefiting from, or creating computing machinery. It includes the study and expe ...
-based operating systems, such as those in the
Windows 9x
Windows 9x is a generic term referring to a series of Microsoft Windows
Microsoft Windows, commonly referred to as Windows, is a group of several families, all of which are developed and marketed by . Each family caters to a certain se ...
and
Windows NT
Windows NT is a proprietary
{{Short pages monitor