Tag: smart pointers
7 posts
-
C++ RAII Explained | Why Constructors and Destructors Prevent Leaks
A deep dive into C++ RAII grounded in a real production connection-leak incident, covering exception safety, the C++ Core Guidelines, and composable ownership.
-
shared_ptr and weak_ptr Internals: Control Blocks, Cycles, enable_shared_from_this and Aliasing
std::shared_ptr reference counting, control blocks, weak_ptr observers, cycles, enable_shared_from_this, aliasing, custom deleters, and production patterns in modern C++.
-
std::unique_ptr: Exclusive Ownership, make_unique, Custom Deleters and Moving Ownership
std::unique_ptr explained: RAII, make_unique, custom deleters, arrays, move semantics, PIMPL, containers, and exception-safe factories.
-
C++ Smart Pointers
C++ smart pointers: unique_ptr, shared_ptr, weak_ptr, make_unique, make_shared—fix circular references when memory grows despite no Valgrind leak.
-
C++ Circular References: shared_ptr Leaks and Breaking
Why shared_ptr cycles leak memory, how weak_ptr breaks cycles, parent/child and cache/observer patterns, use_count debugging, Valgrind, and ASan.
-
C++ shared_ptr Circular References and weak_ptr: Trees, Observers, Graphs, Caches
Break shared_ptr reference cycles with weak_ptr: why cycles leak memory, using lock() and expired() safely, parent-child trees, observers, graphs and caches, enable_shared_from_this pitfalls, and how to diagnose leaks.
-
C++ shared_ptr vs unique_ptr: Ownership, Overhead, Thread Safety and When to Use Each
shared_ptr vs unique_ptr: prefer unique_ptr by default; use shared_ptr for shared ownership. Raw pointers in C++ do not communicate ownership.