Skip to content
C++

Memory Management

12 pages — smart pointers, allocators, RAII, placement new, and PMR.

construct_at / destroy_at

Low-level object lifetime utilities for constructing and destroying objects in raw memory without invoking operator new or delete.

Custom Allocators and PMR

C++ custom allocators and C++17 polymorphic memory resources: arena, pool, PMR containers, allocator propagation, and zero-heap hot paths.

Memory Management

C++ memory management — RAII, smart pointers, arenas, PMR allocators, object pools, placement new, and avoiding heap pitfalls.

observer_ptr

A non-owning pointer wrapper from the C++ Library Fundamentals TS that makes non-ownership explicit at the type level.

Placement new and Manual Object Lifetime

Construct objects in pre-allocated memory using placement new, std::construct_at, std::destroy_at, and std::launder for allocators, pools, and variant storage.

Smart Pointers

unique_ptr, shared_ptr, and weak_ptr — ownership semantics, control block internals, custom deleters, cycle breaking, and enable_shared_from_this.

std::out_ptr and std::inout_ptr

C++23 RAII proxy adapters that let smart pointers be passed directly to C-style T** output-parameter APIs without unsafe casts or manual resets.

std::pmr::memory_resource

Abstract base class for C++17 polymorphic memory resources; decouples allocation strategy from container type via runtime polymorphism.

std::shared_ptr

A reference-counted smart pointer that enables shared ownership of a dynamically allocated object, deleting it when the last owner is destroyed.

std::unique_ptr

Exclusive-ownership smart pointer that automatically frees its managed object when it goes out of scope, with zero overhead over a raw pointer.

std::weak_ptr

A non-owning smart pointer that observes a shared_ptr-managed object without extending its lifetime, enabling cycle-breaking and safe expiry detection.

weak_ptr Patterns

C++ weak_ptr usage patterns — breaking cycles, observers, caches, enable_shared_from_this, and thread-safe access via lock().