What RAM is, and how it is fitted

Video 035 of 140 in Virtualization Foundations, in the unit “Memory: RAM, addresses and virtual memory”. 4:01, with English and Hindi audio.

A processor can calculate very fast, but it can only work on data that is already in memory. If memory is slow or badly fitted, a fast processor spends its time waiting. This article explains why a program's data must sit in RAM, how memory sticks called DIMMs connect to the processor through channels, and how to ask Ubuntu what memory is fitted in a server.

What you will learn

Why a program's data must sit in RAM

A disk keeps data safely, even when the power is off. But a disk is far too slow for a processor to wait on. So a program's working data is copied into RAM, which stands for random access memory. In RAM, any byte can be reached in about the same time, and the processor reads and writes this working copy directly.

RAM is volatile. Its contents are lost when the power goes off, so anything that must survive a power cut stays on the disk.

How memory sticks reach the processor

The width and speed of those channels set how much data can move at once.

How channels and transfer rate set memory speed

A memory controller can run several channels at once. More channels let more data move in the same moment. Speed is written as a transfer rate. DDR4-3200 memory makes three thousand two hundred million transfers every second, which is written as 3200 MT/s, meaning megatransfers per second.

Each transfer carries eight bytes over one channel. Treat any speed you work out from these numbers as a best case, because a program does not always get it.

Note: An empty channel wastes the capacity and speed you paid for. Its wires sit idle, and the server runs below its best speed.

What goes wrong with memory, and how you notice it

You would notice slow programs, memory errors in the system log, or a server that stops during start-up.

How to ask Ubuntu what memory is fitted

On Ubuntu, the dmidecode command reads the hardware record that the firmware keeps. It needs root rights, so it starts with sudo. It shows each memory slot, with its size and its type.

Ask the firmware record which memory slots are fitted
sudo dmidecode -t memory

The kernel, which is the core of the operating system, sees memory as blocks. The lsmem command lists those blocks and the total memory the kernel can use.

List the memory blocks the kernel can use
lsmem

Try it yourself

You need an Ubuntu machine and an account with sudo rights. You will see one block for each memory slot, then the memory blocks the kernel can use.

  1. Ask the firmware record for the memory slots. The command needs root rights, so it starts with sudo.

    sudo dmidecode -t memory

    What you should see: One block for each memory slot, with its size, its type and its speed.

  2. List the memory blocks the kernel can use, and the total online memory.

    lsmem

    What you should see: The memory blocks as the kernel sees them, and the total online memory.

Terms

RAM
Random access memory, the fast working memory where a running program keeps the data it is using.
DIMM
A small circuit board carrying memory chips, which plugs into a slot on the server's main board.
Channel
A group of wires that serves a set of memory slots and carries data between them and the processor.
Memory controller
The part inside the processor that sends every memory read and write down the channels.

Check yourself

Why is a program's working data copied from the disk into RAM?

A disk is far too slow for a processor to wait on, while RAM lets the processor reach the data quickly.

What happens to the contents of RAM when the power goes off?

They are lost, because RAM is volatile. Anything that must survive a power cut has to stay on the disk.

Which command shows the memory slots recorded by the firmware?

The command sudo dmidecode -t memory, which needs root rights. It shows the size and type of each memory slot.

Previous: Why privilege matters for virtualization. Next: Bits, bytes, GB and GiB.