Tag: weak_ptr
5 posts
-
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++.
-
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.