Tagged articles
4 articles
Page 1 of 1
IT Services Circle
IT Services Circle
Feb 9, 2026 · Fundamentals

Why Misusing std::shared_ptr Slows Your C++ Code and How to Fix It

This article explores common pitfalls when using std::shared_ptr in C++, including unnecessary copying, extra heap allocations, cyclic references, and subtle memory retention with make_shared, provides benchmark comparisons, and offers practical guidelines such as preferring const‑reference passing, using std::make_shared, and employing weak_ptr to break cycles.

c++memory-managementperformance
0 likes · 10 min read
Why Misusing std::shared_ptr Slows Your C++ Code and How to Fix It
Deepin Linux
Deepin Linux
Sep 11, 2025 · Fundamentals

Mastering C++ Smart Pointers: unique_ptr, shared_ptr, and weak_ptr Explained

This article introduces C++ smart pointers—unique_ptr, shared_ptr, and weak_ptr—explaining their RAII‑based automatic memory management, usage patterns, performance considerations, common pitfalls such as cyclic references, and practical examples including factory patterns and GUI data sharing, while also covering size and custom deleters.

Memory Managementc++shared_ptr
0 likes · 24 min read
Mastering C++ Smart Pointers: unique_ptr, shared_ptr, and weak_ptr Explained
Deepin Linux
Deepin Linux
Dec 26, 2024 · Fundamentals

Understanding C++ Smart Pointers: Types, Mechanisms, and Best Practices

This article explains how C++ smart pointers—unique_ptr, shared_ptr, weak_ptr and the deprecated auto_ptr—use RAII and reference‑counting to automate memory management, avoid leaks and dangling pointers, and provide guidelines, performance analysis, and practical usage tips for modern C++ development.

C++Memory ManagementRAII
0 likes · 36 min read
Understanding C++ Smart Pointers: Types, Mechanisms, and Best Practices
Tencent Cloud Developer
Tencent Cloud Developer
Jan 4, 2022 · Fundamentals

Smart Pointers in C++: Problems Solved, Usage, Best Practices, and Implementation Details

C++11 smart pointers—unique_ptr, shared_ptr, and weak_ptr—replace manual new/delete by providing exclusive, shared, and non‑owning ownership semantics, automatically preventing leaks and dangling references, simplifying multithreaded code, and, when used with best‑practice guidelines, avoid common pitfalls such as double deletions and cyclic dependencies.

C++multithreadingshared_ptr
0 likes · 24 min read
Smart Pointers in C++: Problems Solved, Usage, Best Practices, and Implementation Details