Chapter 3 of 10All chapters
Chapter 3 of 10
Memory
Fast, volatile and always too small.
What RAM does
Memory holds the data and code currently in use. It is thousands of times faster than storage and loses everything when power stops, which is why work must be saved.
- Running out means swapping to disk, which feels like the machine has stopped.
- More RAM helps until you stop swapping, then makes no difference at all.
Cache
Small caches inside the processor hold recently used data. A cache miss costs hundreds of cycles, which is why data laid out contiguously in memory runs so much faster than data scattered across it.