Module M02 · 2 of 35 in teaching order · Beginner
Memory Model
What a variable, a reference and a buffer really are, and why contiguous memory is fast.
Lessons
Value types, reference types, pointers and aliases in C#, Python, Java and C++: what b = a copies, and why a change through one name can show up in another.
Where locals and objects live: one stack frame per call, objects on the heap, what a return frees, and what stack overflow does in C#, Python, Java and C++.
Why arrays index in O(1), why traversing contiguous memory is cache friendly and linked nodes are not, and where fragmentation comes from. C#, Python, Java, C++.
A growing dynamic array moves to a new buffer. What that does to pointers, spans, iterators and views in C++, C#, Java and Python, and how to stay safe.
Which objects are garbage, how mark-and-sweep finds them, reference counting and cycles, and deterministic cleanup with using, with, try-with-resources and RAII.
Topics this module covers
The full module scope. Topics without a lesson above are not written yet.
- addresses
- stack and heap
- values and references
- pointers
- contiguous storage
- allocation
- GC and RAII
- copying
- cache locality
- fragmentation
- call stack
- overflow