Lifetimes, allocation, and managed memory

Reason about ownership and object lifetime, then compare runtime allocation and collection mechanisms with explicit safety boundaries.

10 published lessons1 module231 min of guided study
  1. 01
    Lifetimes, allocation, and managed memorycore · 10 lessons

Follow the path or begin with a question. Every lesson is open.

Your notebook0 of 10 lessons completed

Your place, at your pace. Progress is optional and saved only in this browser when available.

Inside this module

Each lesson includes an interactive lab

Lifetimes, allocation, and managed memory

Reason about ownership and object lifetime, then compare runtime allocation and collection mechanisms with explicit safety boundaries.

  1. 01

    Object lifetimes: when an address stops being a resource

    Separate allocation, object validity, pointer identity, and retention before deciding when a buffer may be reclaimed.

    21 min
  2. 02

    Ownership and borrowing: make release responsibility explicit

    Use moves, borrows, and explicit copies to design resource lifecycles without confusing a reference with an owner.

    22 min
  3. 03

    Aliasing and mutability: which writes can affect a read?

    Trace overlapping accesses, explain optimization assumptions, and distinguish interior mutability from unrestricted shared mutation.

    23 min
  4. 04

    Spatial safety: prove the entire access fits

    Check offsets, access widths, alignment, and size arithmetic instead of treating a non-null pointer as a valid buffer.

    22 min
  5. 05

    Reference counting: local release rules and cyclic retention

    Trace strong and weak ownership edges, identify cycles, and separate atomic handle management from safe mutation.

    23 min
  6. 06

    Tracing collection: find the objects reachable from roots

    Compute a reachable object graph, compare marking with reclamation, and diagnose retained memory that a collector cannot discard.

    23 min
  7. 07

    Generational collection: remember edges across the boundary

    Explain partial-heap tracing, old-to-young references, remembered sets, and why write barriers preserve collection correctness.

    24 min
  8. 08

    Compaction and pause budgets: pay for movement deliberately

    Relate fragmentation, relocation, pinning, and collection work to a measured latency budget without promising universal pause guarantees.

    24 min
  9. 09

    Arenas and pools: reuse storage without reusing stale meaning

    Compare bulk-lifetime arenas with reusable slots while accounting for alignment, cleanup, retention, and stale handles.

    24 min
  10. 10

    Foreign-function boundaries: carry ownership across the ABI

    Specify layout, allocation pairs, buffer validity, asynchronous retention, and cleanup before presenting a safe native wrapper.

    25 min
All engineering modules