Memory

This part of the C course is memory: the stack and the heap, malloc, calloc and realloc, the leaks and double frees that follow them, and the arenas and pools that replace many small allocations with one. It closes with undefined behaviour and with the sanitizers that catch it in a test run instead of in production.

6.1 The stack and the heap frames, automatic objects, heap lifetime, when to allocate Open 6.2 malloc, calloc and realloc allocation, zeroing, growth, free, alignment Open 6.3 Memory leaks and ownership leak hunting, double free, use after free, ownership rules Open 6.4 Arenas and pools bump allocator, free lists, bulk reset, cache locality Open 6.5 Undefined behaviour overflow, out-of-bounds, uninitialised reads, strict aliasing Open 6.6 Sanitizers AddressSanitizer, UndefinedBehaviorSanitizer, LeakSanitizer Open

Lessons