“Leak-Freedom in C++... By Default.”
summary
Argues a concrete, prioritized rule set: prefer scoped lifetime (stack or member), otherwise use unique_ptr then shared_ptr and avoid explicit delete and cross-module ownership cycles; shows exact patterns — const unique_ptr for pimpl, vector<unique_ptr> children with raw parent pointer for trees, iterative destruction to avoid stack overflow, shared_ptr+weak for caches and DAGs. Presents a working experiment, a deferred heap prototype on GitHub where collect runs destructors to reclaim cyclic graphs; prototype attracted several PRs and a small puzzle showed ~10/100 correct solutions.
AI-written summary · about
chapters (13)
- 0:00Introduction and guidelines
- 2:04Three rules of leak freedom
- 5:40Applying the rules
- 11:14Tree structures and recursion
- 16:54Iterative destruction
- 22:37Linked lists and unique ownership
- 26:45Graphs and shared ownership
- 31:21Factories and cyclic ownership
- 36:52Handling ownership cycles
- 42:28Manual graph management
- 50:24Mark-and-sweep traversal
- 55:52Final recap and Q&A
- 59:16Experimental deferred heap
related talks
01h 33mSafe and Sane C++ Types
53mSmart Pointers in C++
09mLifetime and Ownership - Ownership is Decided Locally
01h 23mRethink Polymorphism in C++
01h 01mBack to Basics: Smart Pointers
01h 11mDynamic Memory Allocation Challenges in C++ Safety Critical Systems
01h 22mThese 10 tricks that only library implementors know!
01h 01mRecipes for Reducing Allocations by C++ Containers
