Memory management library
Smart pointers, allocators and PMR, raw memory algorithms, operator new/delete, and lifetime-oriented utilities.
The C++ memory area spans ownership models, allocation strategies, polymorphic memory resources, raw storage algorithms, low-level pointer utilities, and the language-adjacent rules around object lifetime. This hub is the curated starting point when the problem is about how objects are stored, owned, created, destroyed, or allocated.
# Start Here
Exclusive ownership
Use unique_ptr when one owner controls an object or array and transfer-by-move is the intended ownership model.
Shared ownership
Use shared ownership when multiple parts of a program intentionally co-own an object and lifetime ends with the last owner.
Allocators and PMR
Start here when allocation strategy matters more than pointer ownership, especially for containers, arenas, and custom memory-resource wiring.
Raw storage and object lifetime
Use this route when the question is about `operator new/delete`, uninitialized storage, constructing into raw memory, or starting object lifetime explicitly.
new/delete · construct_at · uninitialized_copy · start_lifetime_as
# Quick Map
| If you need to... | Start with | Why |
|---|---|---|
| Own an object with a single clear owner | unique_ptr | It expresses exclusive ownership directly and is the default RAII pointer for heap objects that do not require shared lifetime. |
| Share ownership across multiple objects or callbacks | shared_ptr, weak_ptr | These types model shared control blocks and non-owning observers for graph-like lifetime structures. |
| Customize allocation for containers or object construction | allocator, allocator_traits, polymorphic_allocator | Use the allocator path when the issue is allocation policy, propagation, fancy pointers, or container integration. |
| Use arena-like or shared memory resources | memory_resource, monotonic_buffer_resource, synchronized_pool_resource | PMR is the standardized route for runtime-selectable allocation backends. |
| Allocate raw storage and construct objects manually | new/delete, construct_at, destroy, uninitialized algorithms | This is the route for low-level object placement and lifetime control in buffers that do not yet hold live objects. |
| Recover raw addresses from fancy pointers or contiguous handles | to_address, pointer_traits | These helpers bridge pointer-like abstractions with raw-address-based low-level code. |
| Reach the C allocation surface | C memory management, C documentation | Use this route when the code is intentionally using `malloc`/`free`-style APIs or interoperating with C allocation rules. |
# Raw Memory And Lifetime Helpers
| Helper | Use it for | Primary destinations |
|---|---|---|
| Object construction and destruction | Explicitly creating and tearing down objects in already-allocated storage. | construct_at, destroy, destroy_at |
| Uninitialized algorithms | Copying, moving, filling, or default-constructing across raw storage ranges. | uninitialized_copy, uninitialized_fill, uninitialized_default_construct |
| Lifetime start utilities | Beginning object lifetime in storage without the classic placement-new model alone. | start_lifetime_as |
| Address and alignment helpers | Working with fancy pointers, raw addresses, alignment contracts, and address recovery. | to_address, addressof, align, assume_aligned |
# Modern Additions
| Standard | What changed navigation-wise |
|---|---|
| C++11 | unique_ptr, shared_ptr, weak_ptr, allocator traits, and the new allocation/lifetime model became the dominant modern memory story. |
| C++17 | PMR introduced a second major allocation path centered on memory_resource and polymorphic_allocator. |
| C++20 | construct_at, to_address, and ranges-aware/lifetime-adjacent helpers made raw-memory code more explicit and more reusable. |
| C++23 | start_lifetime_as, out_ptr/inout_ptr, and allocator refinements expanded the interoperability and lifetime-control surface. |
| C++26 | New alignment and allocation-result helpers continue broadening the low-level memory toolset beyond classic smart-pointer navigation. |
# Boundary Lines
| This hub covers | Use a different hub for |
|---|---|
| Ownership, allocation strategies, raw storage algorithms, and lifetime-oriented memory helpers. | Containers for container selection and access models, Utility for general-purpose support types, and Type support for traits/limits not primarily about storage or ownership. |
| C++ memory-management abstractions. | C memory when you need the plain C allocation family or cross-language allocation guidance. |