---
title: "Memory"
url: https://www.daytona.com/compute-glossary/hardware/memory
---

# Memory

Part of the [Compute Glossary](https://www.daytona.com/compute-glossary.md), section [Hardware](https://www.daytona.com/compute-glossary/hardware.md).

Also called RAM, Main memory.

Memory is the working storage of a computer, where programs and their data sit while a processor uses them. In a server it almost always means DRAM, chips on modules plugged in next to the [CPU](https://www.daytona.com/compute-glossary/hardware/cpu.md). DRAM stores each bit as a tiny electric charge that leaks away, so the chips refresh their contents many times a second. Server memory also corrects errors, fixing a single flipped bit before a program reads it.

Memory sits between the caches of the processor and the disks. It is much larger than cache and has a far lower [latency](https://www.daytona.com/compute-glossary/foundations/latency.md) than any disk, but it loses its contents when the power goes off. Anything that must survive a restart therefore has to be written to disk. A [snapshot](https://www.daytona.com/compute-glossary/sandboxes/snapshot.md) of a running machine has to save its memory for the same reason, so a guest with more memory takes longer to snapshot.

A running program keeps its code and data in memory and reads and writes them as it needs, so the amount of memory bounds how many programs a machine can hold at once. On servers with several processors, where that memory sits also affects speed, a layout called NUMA. The amount in a server is fixed by the number and size of the modules in its slots. Each processor also limits how much memory it can reach, through the number of channels it supports.

## Virtual memory

Virtual memory is a scheme in which programs never see physical addresses. Each [process](https://www.daytona.com/compute-glossary/kernel/process.md) gets its own virtual address space, and the processor translates every address through page tables that the [kernel](https://www.daytona.com/compute-glossary/kernel/kernel.md) maintains. A small cache on the processor, the TLB, keeps recent translations so that most accesses skip the walk through the tables. Each program can then be written as if it had the whole address range to itself.

Memory is handed out in pages, with larger huge pages for programs that touch a lot of memory. Translation also keeps processes apart, because a process can reach only the pages mapped into its own tables. The kernel maps a page only when the program first touches it, so a program can reserve far more than it uses. Huge pages get harder to find as memory fragments, and the kernel may have to move pages around to make one.

Translation lets the kernel share pages between processes that hold the same data, or mark them copy-on-write so that a copy costs nothing until one side writes. Virtual machines add a second layer of translation, controlled by the [hypervisor](https://www.daytona.com/compute-glossary/virtualization/hypervisor.md). Forking a process relies on this, since parent and child share every page until one of them writes. Inside a guest, a translation missing from the TLB takes many more memory reads, which is why huge pages help guests even more.

| **Page size** | **Description**                                                                     |
| ------------- | ----------------------------------------------------------------------------------- |
| **4 KiB**     | A 4 KiB page is the usual size.                                                     |
| **2 MiB**     | A 2 MiB huge page on x86-64 cuts translation work for programs with large memory.   |
| **1 GiB**     | A 1 GiB huge page on x86-64 suits programs that touch very large amounts of memory. |

## Memory as a limit

Memory as a limit is the way a shortage of memory stops a workload, unlike a shortage of processor time. A workload that gets less processor time simply runs slower, but memory cannot be stretched that way. Processor time renews every moment, while memory stays taken until it is freed. Memory holds the state of a program, so taking any of it away means losing that data or moving it elsewhere.

A workload that gets less memory than it needs does not degrade gently. It swaps to disk and slows sharply, or the kernel kills it to free memory for others. Swapping turns memory reads into disk reads, which take many times longer. The kernel picks what to kill by memory use and by a priority it is given, so the victim may not be the workload that caused the shortage.

On a host that runs many virtual machines, memory is usually the resource that runs out first. It bounds how many guests fit on one [server](https://www.daytona.com/compute-glossary/hardware/server.md) more than the core count does. An idle guest uses almost no processor time, but it still holds its memory. Hosts are therefore often sized by their memory, with cores chosen to match.

## Memory reclamation

Memory reclamation is the set of ways a host takes back memory that guests hold but do not use. A balloon driver inside a guest can return unused pages to the host, and identical pages across guests can be merged. The balloon works by asking the guest kernel for pages, which it then hands to the host as unused. Merging scans memory for pages with the same contents and keeps one shared copy, marked copy-on-write.

Hosts can also swap idle guests out to disk, which frees memory at the cost of a slow return when the guest wakes. Each of these lets a host [overcommit](https://www.daytona.com/compute-glossary/infrastructure/overcommit.md) memory, promising guests more than it has in total. Swapping by the host is blunt, since it cannot tell which guest pages matter the way the guest kernel can. Overcommit raises the number of guests per host, which lowers the cost of each one.

The risk shows when many guests use their full share at once. The host then has nothing left to reclaim, so it may swap pages to disk, slowing workloads sharply, or kill some of them. Merging adds a risk of its own, because a guest can time its writes to learn whether a page was shared with another guest. Many hosts therefore turn merging off between tenants that do not trust each other.

## Related terms

- [CPU](https://www.daytona.com/compute-glossary/hardware/cpu.md)
- [Latency](https://www.daytona.com/compute-glossary/foundations/latency.md)
- [Overcommit](https://www.daytona.com/compute-glossary/infrastructure/overcommit.md)
