Memory Management

Lessons in this group, roughly in build order:

  • stack-vs-heap — Every C++ object lives in one of two regions with very different cost and lifetime rules: the automatic…
  • new-delete — new allocates raw storage on the heap and runs a constructor; delete runs the destructor and frees the…
  • raii — Resource Acquisition Is Initialization: bind a resource (memory, file, lock, socket) to the lifetime of a…
  • object-lifetime — An object’s lifetime is the span between the completion of its constructor and the start of its…
  • move-semantics-rvalue-references — An rvalue reference (T&&) binds to objects that are about to expire, letting a move steal their resources…
  • copy-vs-move — Copying duplicates an object’s resources (the source stays intact); moving transfers them (the source is…