On this page
  1. Pointers, References & Indirection
  2. Contents
  3. Memory Addresses & Dereferencing
  4. Classic Pointer Hazards
  5. Pointer Chasing & CPU Cache Locality

Pointers, References & Indirection

Prev: Call Stack & Heap | Up: memory_and_execution | Next: Memory Management Models
Rel: Value vs. Reference Semantics, Memory Management Models, C Pointers & Pointer Arithmetic
Ref: Wikipedia — Pointer (Computer Programming)
Tags: #public #prog #programming #memory #pointers


Contents


Memory Addresses & Dereferencing

A pointer is a variable whose value is the numeric memory address of another value.

  Variable p (at 0x1000)       Variable x (at 0x2040)
  ┌────────────────────┐       ┌────────────────────┐
  │      0x2040        │ ────> │         42         │
  └────────────────────┘       └────────────────────┘

Classic Pointer Hazards


Pointer Chasing & CPU Cache Locality

CPUs fetch memory in cache lines (typically 64 bytes). Contiguous arrays let hardware prefetchers stream data at full speed, whereas pointer-heavy linked lists or boxed objects scatter nodes across the heap (pointer chasing), causing orders-of-magnitude more cache misses.

Linked from

Related notes