Agent Memory Architectures · 1 of 4
Kinds of Memory
Computer memory is a hierarchy of places to keep state, each trading speed, capacity, cost, and durability in a different way.
A computer is not just a machine that calculates; it is a machine that remembers. Every click, message, payment, image, model weight, and line of code must live somewhere, even if only for a few billionths of a second. The reason memory feels complicated is that there is no single place called memory. There are many kinds, arranged from tiny and fast to vast and slow, and good systems work because they put each piece of information in the right place at the right time.
Memory starts with state
At the lowest level, memory stores state: a fact the machine can use later. That fact may be as small as one bit, meaning a single 0 or 1, or as large as a database holding years of business history. A byte is eight bits, and most practical measurements of computer memory are built from bytes.
The useful questions are simple. How fast can the machine read or write it? How much can it hold? How expensive is each byte? Does the information remain after power is lost? No one kind of memory wins all four questions. Fast memory is usually small and costly. Large memory is usually slower. Durable memory usually takes longer to change.
This is why systems use a memory hierarchy. The central processing unit, or CPU, keeps a few immediate values very close. Recently used data sits nearby in cache. Active programs live in random-access memory, or RAM. Data that must survive lives in persistent storage such as a solid-state drive, or SSD, a hard disk drive, or HDD, or a remote storage service.
Registers and cache: the processor’s short-term memory
The CPU can only compute with values it can reach quickly. Its closest memory is a small set of registers. A register holds a value the CPU is using right now, such as a number being added or the address of the next instruction. Registers are extremely fast because they are built into the processor itself, but there are very few of them.
Cache is the next layer out. A cache keeps copies of data that the CPU is likely to need soon. The idea is based on locality: programs tend to reuse the same data and nearby data over short periods of time. If the data is in cache, the CPU avoids a slower trip to main memory.
Modern processors often have several cache levels. A first-level cache is very small and very fast. Lower levels are larger and slower, but still faster than RAM. Software usually does not place individual values in these caches directly, but software design strongly affects whether caches help. Tight data layouts, predictable access patterns, and avoiding unnecessary copying can matter as much as a faster processor.
RAM: the active workspace
Random-access memory, or RAM, is the computer’s active workspace. It is called random access because the machine can reach any location directly, rather than reading through earlier locations first. When you open an application, load a web page, or run a service, the code and active data are placed in RAM so the CPU can work with them.
Most system RAM is dynamic random-access memory, or DRAM. DRAM stores bits in tiny electrical charges that must be refreshed repeatedly, so it forgets when power is removed. Static random-access memory, or SRAM, is faster and often used for cache, but it uses more chip area and costs more per byte.
The important practical idea is the working set: the data a program needs during a period of time. If the working set fits comfortably in RAM, the program can run smoothly. If it does not, the operating system must move data between RAM and slower storage, and performance can collapse.
- More RAM helps when active data does not fit, not when the bottleneck is computation or network waiting.
- A memory leak is a program defect where memory is no longer useful but is not released.
- High memory use is not always bad; unused RAM can often be used as cache to avoid slower storage reads.
Persistent storage: memory that survives
Persistent storage keeps data after power is lost. This is where files, databases, logs, backups, and object stores live. Storage is memory in the broad sense, but it has different promises from RAM: it is larger and durable, but slower to read and especially slower to write safely.
An SSD stores data in flash memory with no spinning parts. It usually offers much lower latency than an HDD, which stores data magnetically on rotating platters. Remote storage, such as a network file system or cloud object store, can be much larger and easier to share, but it adds network delay and depends on another service.
Durability is not the same as correctness. A system may write data to storage but lose it if the write was cached and not committed. It may commit data on one machine and still lose access if that machine fails. Serious systems define when a write is considered durable and how many independent copies must exist before telling a user that work is saved.
Virtual memory: a useful illusion
Programs do not usually see physical RAM directly. They see virtual memory: a private address space created by the operating system and hardware. An address space is the range of memory addresses a program is allowed to use. This makes each program feel as if it has its own clean memory, even while many programs share the same machine.
A memory management unit, or MMU, translates virtual addresses into physical addresses. It also enforces protection, so one process cannot freely read or overwrite another process’s memory. This is one of the foundations of reliability and security in modern computers.
Virtual memory also lets the operating system move less-used memory pages to storage, a process often called paging or swapping. A page is a fixed-size block of memory used for management. Paging allows programs to use more virtual memory than there is physical RAM, but if the system pages constantly, it spends more time moving data than doing useful work.
Shared, distributed, and specialized memory
Memory is not always inside one general-purpose computer. A graphics processing unit, or GPU, often has its own high-bandwidth memory for images, simulations, and machine learning calculations. This memory can feed many simple calculations in parallel, but moving data between CPU memory and GPU memory may be expensive.
On larger servers, not all RAM is equally close to every processor socket. Non-uniform memory access, or NUMA, means a CPU can reach local memory faster than memory attached to another CPU. NUMA effects are often invisible at small scale, then become important when high-throughput software is pushed hard.
Distributed systems add another meaning of memory: keeping copies across machines. A cache may sit in front of a database. A message broker may hold events until consumers read them. A replicated database may keep the same record in several places. These memories improve speed or resilience, but they also introduce the hard question of consistency: when two readers ask for the same fact, must they see the same answer at the same time?
The decisions memory forces
Memory choices become architecture choices. A leader deciding whether to buy larger servers, tune software, add a cache, change a database, or redesign a workflow is really deciding where state should live and what guarantees it needs.
The first question is not “How much memory can we afford?” but “What must be fast, what must be durable, and what must be shared?” A session token, a shopping cart, an audit log, a trained model, and a financial transaction all have different memory needs. Treating them alike leads either to waste or to risk.
Cost matters, but so does operational simplicity. A cache can reduce latency and database load, but it can also serve stale data or fail separately. Replication can improve availability, but it can make writes slower and conflict handling harder. More RAM can postpone a redesign, but it may hide a memory leak until the next growth step.
- Choose RAM capacity from measured working sets, not from average utilization alone.
- Use caches for data that can tolerate being briefly stale or can be safely recomputed.
- Put durable records in storage systems with explicit write and replication guarantees.
- Measure tail latency, not just average latency, because memory misses and storage waits often show up in the slowest requests.
- Make ownership clear: every important piece of state should have one system of record.
Good memory design is explicit
Many failures are memory failures in disguise. A service restarts and loses in-memory state that should have been durable. A cache returns an old value after the database changed. A queue grows because consumers are slower than producers. A machine has enough average RAM, but one batch job pushes it into swapping. A data pipeline writes a file but does not make the write atomic, so readers see a partial result.
Good designs say out loud what each memory is for. They separate temporary state from durable records. They define cache expiration and invalidation. They plan for restart, retry, and recovery. They measure memory pressure before users notice it. They decide which facts must be strongly consistent and which can be approximate or delayed.
The simple model remains useful at every scale: memory is where state waits for its next use. The closer it is, the faster it is. The farther and more redundant it is, the more likely it is to survive. Engineering is the art of placing each kind of state where those trade-offs fit the job.
Key takeaways
- Memory is a hierarchy, not a single component.
- Registers and cache are tiny and fast; RAM is the active workspace; persistent storage survives power loss.
- Virtual memory gives programs private address spaces and lets the operating system manage physical RAM safely.
- Performance problems often come from moving data between memory layers, not from computation itself.
- Architectural choices should match each kind of state to its needs for speed, durability, sharing, and consistency.
Glossary
- Bit
- A bit is the smallest unit of digital information, holding either 0 or 1.
- Byte
- A byte is a group of eight bits and is the usual base unit for measuring memory size.
- Register
- A register is a tiny storage location inside a processor used for values needed immediately.
- Cache
- A cache is a faster memory that keeps copies of data likely to be used soon.
- Random-access memory
- Random-access memory is active working memory that can be read or written at directly addressed locations.
- Persistent storage
- Persistent storage is memory that keeps data after power is removed.
- Virtual memory
- Virtual memory is the private memory view an operating system gives to a program while mapping it to real physical memory.
- Working set
- A working set is the data a program actively needs during a particular period of execution.
- Latency
- Latency is the time delay between asking for something and receiving the result.