Web & Dev

Computer Memory Architecture

DRAM, cache, virtual memory, and paging — how CPUs access data.

DRAM generations

TypeData ratePeak bandwidth (single channel)
DDR3-16001600 MT/s12.8 GB/s
DDR4-24002400 MT/s19.2 GB/s
DDR4-32003200 MT/s25.6 GB/s
DDR5-48004800 MT/s38.4 GB/s
DDR5-64006400 MT/s51.2 GB/s
LPDDR56400 MT/smobile / soldered
HBM2e3.6 Gbps/pin~460 GB/s stack
HBM36.4 Gbps/pin~800 GB/s stack

Virtual memory

Page size4 KB default; huge pages 2 MB or 1 GB
Page tableMaps virtual → physical — multi-level (typically 4 on x86-64)
TLBCaches recent translations
TLB missCosts ~100 ns on x86; use huge pages for large working sets
Swap / pagingMove cold pages to disk — modern systems avoid swap when possible

Cache behavior

Cache line64 bytes on x86 / ARM
Associativity8–16-way typical
CoherenceMESI / MOESI between cores
False sharingDifferent cores hitting same cache line — pad to 64 B
Write-backDirty lines flushed to next level on eviction

Tips

  • Design data for locality — contiguous arrays beat linked lists for iteration.
  • Align hot data on cache-line boundaries.
  • Prefetch: modern CPUs detect sequential access automatically; manual prefetch hints help for irregular patterns.
  • Avoid false sharing between threads by padding or separating per-thread data.
Was this article helpful?