Table of Contents

Virtual Memory - Paging or Swapping

About

A transfer of pages between main memory (RAM) and an secondary storage such as hard disk drive, is referred to as paging or swapping.

It's the ability to use the disk to extend the amount of RAM available.

When an operating system or executive uses paging, the paging mechanism is transparent to an application program. All that the application sees is a linear address space.

The linear address space can only be paged when using:

Usage:

In Linux, true swapping is exceedingly rare, therefore the terms paging and swapping often are used interchangeably.

Using swap space is not inherently bad. Rather, it's intense paging activity that's problematic. For instance, if your most-memory-intensive application is idle, it's fine for portions of it to be set aside when another large job is active. Memory pages belonging to an idle application are better set aside so the kernel can use physical memory for disk buffering.

Swap usage is a result of paging due to possible memory leaks or a high number of concurrent tasks.

Management

IA-32 architecture’s paging mechanism

In addition, IA-32 architecture’s paging mechanism includes extensions that support:

Disabled

Paging disabled is also known as direct mapping.

Each linear address has a one-to-one correspondence with a physical address. Linear addresses are sent out on the processor’s address lines without translation.

Enabled

linear address space is divided into pages which are mapped to virtual memory.

The pages of virtual memory are then mapped as needed into physical memory.

Page

in

When pages are returned to physical memory, the event is called a page-in. See Virtual Memory - Page-In

out

When pages are written to disk, the event is called a page-out. See Virtual Memory - Page Out

fault

A page fault occurs when the kernel needs a page, finds it doesn't exist in physical memory because it has been paged-out, and re-reads it in from disk.

See Memory - Page Fault Exception

How to calculate the Swap Space ?

You need hard disk drives with sufficient space for swap. You can calculate the required swap space as follows:

You can display and – if required – modify the existing swap space: Linux - Swap / Paging