Allocators: The Good Parts
summary
Argues that C++17’s pmr model makes allocators practical, showing how to derive a memory resource (override do_allocate/do_deallocate/do_is_equal), wrap it in polymorphic_allocator<std::byte>, and build an allocator-aware singly linked list. Demonstrates a test resource that records allocations, deallocations and high-water marks, and a push_back that produces two allocations (node + string buffer). Explains available resources (new_delete, null, synchronized_pool, monotonic_buffer) and when chaining or throwing on exhaustion is useful.
AI-written summary · about
chapters (9)
- 0:00Introduction and thesis
- 1:27Why allocators exist
- 4:43Historical complexity of allocators
- 13:20Scoped allocator model
- 19:11Polymorphic allocator of byte
- 24:58Building a new memory resource
- 39:13Building a container with allocators
- 55:50Live code demo
- 59:49Conclusion and summary
related talks
01h 01mGetting Allocators out of Our Way
01h 25mTaming Dynamic Memory - An Introduction to Custom Allocators
49mMost Malleable Memory Management Method in C++
01h 03mMost Malleable Memory Management Method
01h 01mRecipes for Reducing Allocations by C++ Containers
06mLightning Talk: Speeding up code with C++17 Polymorphic Memory Resources
01h 26mFrictionless Allocators
01h 13mValue Proposition: Allocator-Aware (AA) Software
