Udemyallen

Mastering Smart Pointers - shared_ptr & weak_ptr

Learn modern C++ memory management for robust, production-ready code. Avoid leaks & exceptions. Build reliable software!

35students
5h 53m
Certificate
Umar Lone
Umar LoneTrainer, developer & founder at Poash Technologies

Course Content

Mastering Smart Pointers - shared_ptr & weak_ptr is an all-levels Udemy course taught by Umar Lone. It runs 5h 53m, is taught in English, and includes a certificate of completion. 35 students have enrolled. It is a paid course, first published October 2025.

Master modern C++ memory management with std::shared_ptr. This practical course provides a deep dive into using smart pointers to eliminate memory errors and build robust applications.

You'll progress from fundamental shared_ptr usage to advanced techniques, including:

  • Copying and Moving shared_ptr: Understand the nuances of these operations for efficient resource management.
  • Resetting shared_ptr: Learn how to safely manage object lifetimes and prevent dangling pointers.
  • Integrating with Functions: Effectively use shared_ptr in function arguments and return types for seamless resource handling.
  • Containers and Polymorphism: Apply shared_ptr to complex data structures, ensuring correct lifetime management in polymorphic scenarios.
  • Multithreading Safety: Develop thread-safe applications by leveraging shared_ptr to avoid data races and memory corruption.

Confront Real-World Bugs: The course directly addresses common memory management pitfalls:

  • Uninitialized and Dangling Pointers: Learn to prevent these errors with smart pointers.
  • Memory Leaks: Identify and eliminate memory leaks in your code.
  • Ownership Mistakes: Understand and avoid subtle ownership issues that can plague large codebases.

Uncover the Inner Workings of shared_ptr: Gain a clear understanding of how shared_ptr functions:

  • Reference Counts: Explore how reference counting ensures proper object destruction.
  • Control Blocks: Understand the role of control blocks in managing object lifetimes.
  • Weak Count: Learn how weak pointers provide a way to observe objects without preventing their destruction.

Manage Non-Memory Resources: Extend RAII beyond heap objects by using custom deleters for:

  • File Pointers: Safely manage file resources.
  • File Handles: Ensure proper handling of file descriptors.
  • Dynamic Linked Library Handles: Properly release library resources.
  • Descriptors: Manage other system resources.

Performance and Debuggability: Compare make_shared with direct new to understand allocation implications and performance differences across compilers (MSVC, GCC, Clang).

Ownership Patterns: Become proficient in advanced ownership techniques:

  • Shared Ownership: Understand when and how to use shared ownership effectively.
  • weak_ptr: Utilize weak pointers for observing objects without preventing destruction.
  • Temporary Borrowing: Safely manage temporary object lifetimes.
  • Cycle Breaking: Resolve circular dependencies in graphs, observers, and caches to prevent memory leaks.

By the end of this course, you'll have the confidence to write leak-free, exception-safe, and maintainable C++ code. Small, runnable examples reinforce each concept, ensuring long-term retention. Improve your C++ skills and build more reliable applications!

$ whoami — the devs behind tutorialsearch.io

Need a web app built? Hire the team behind TutorialSearch.io

We ship fast, production-grade full-stack apps (Next.js, React, edge infra) — the same stack that powers this site.

5.0(131)
5h 3m
beginner
skillshare
5.0(60)
19m
beginner
skillshare
skillshare