programmingconcepts

Track 5

Memory

Where a running program keeps its data: the stack and the heap, references between objects, and how memory is freed.

3 pages, each with a live figure. Read them in order: later pages build on earlier ones.

  1. 5.1Stack vs heapStep throughTwo places a running program keeps data: the stack holds each call's own variables and is freed when the call returns; the heap holds data that has to outlive a call.
  2. 5.2Pointers and referencesStep throughA reference (or pointer) is a value that says where some data lives instead of holding the data itself, so two variables can share one object.
  3. 5.3Garbage collectionStep throughAutomatic memory management that finds objects the program can no longer reach and frees them, so you never call free yourself.

Newsletter

One new concept each week, by email.

Signup opens soon.