Memory hierarchy

16.11.2025

Why should I know all of this?

Every system programmer must know how memory works. This is an optimization issue. Processor spends time not only processing data, but also moving it. Speed of applications depend on this.

Memory hierarchy

Computer memory hierarchy

Memory hierarchy can be represented as a pyramid. On the top of it is the fastest and smallest data storage type and at the bottom is the slowest and biggest data storage type.

Primary storage

CPU Registers, CPU Caches and RAM represent Primary storage. Primary storage, including ROM, EEPROM, and NOR flash, is usually byte-addressable. Such memory is usually connected to the CPU via memory bus, comprising an address bus and a data bus.

Computer storage types

Execute cycle CPU

Cache memory and main memory

Secondary storage (also known as auxilliary storage or external memory) is not directly used by the CPU, but accessed via replacing data to a primary storage with input/output calls (for example asking BIOS to read/write to a sector on a disk). Secondary storage is non-volatile that means it retains data even after shut off. This type of memory is less expensive, can contain more data, but slower than primary storage. Secondary storage is addressable by block and often formatted according to a filesystem format that provides abstraction layer to organize data into files and directories.

In modern computers, hard disk drives (HDDs) and solid-state drives (SSDs) are usually used as secondary storage. Other examples are USB flash drives, floppy disks, magnetic tapes, paper tapes, punched cards and RAM disks.

HDD image

SSD image

USB image

Floppy disk image

Memory card image

Magnetic tape image

Punched tape image

Punched card image

Tertiary storage

Tertiary storage is a storage type that typically involves a robotic access (a robotic arm, for example which mounts and dismounts other data storages). The speed is much slower than secondary storage has, but it allow to store large amounts of data without human access. Typical examples include tape libraries, optical jukeboxes, and massive arrays of idle disks (MAID). Tertiary storage is also known as nearline storage because it is “near to online”.

Robotic arm data storage

Offline storage is a data storage that typically is not under the control of CPU. The medium is recorded, usually in a secondary or tertiary storage device, and then physically removed or disconnected. Unlike tertiary storage, it cannot be accessed without human interaction. It is used to transfer information since the detached medium can easily be physically transported. In modern personal computers, most secondary and tertiary storage media are also used for offline storage.

Network connectivity

A secondary or tertiary storage may connect to a computer utilizing computer networks. This concept does not pertain to the primary storage.

Computer memory hierarchy image