Internals of Shared Memory Management - shared_ptr & weak_ptr

Practical, modern C++ techniques to write safe, fast code using weak & shared ownership, build leak‑free, exception‑safe, production code

Course Description

This course is a practical deep dive into modern C++ memory management through the lens of std::shared_ptr, designed to replace guesswork with clear mental models and repeatable patterns. Starting from basic usage, then copying, moving, resetting, and integrating shared_ptr into function arguments and return types—it builds toward fluency with containers, polymorphism, and multithreading so lifetimes remain correct even as designs grow more complex.


Along the way, lessons confront real bugs head‑on: uninitialized and dangling pointers, memory leaks, and subtle ownership mistakes that typically hide in large codebases. Then the course opens the hood to show how shared_ptr actually works: reference counts, control blocks, weak count, so behavior becomes predictable rather than mysterious. You’ll apply custom deleters to manage non‑memory resources cleanly — file pointers, file handles, dynamic linked library handles, and descriptors—so RAII consistently extends beyond heap objects.


Because performance and debuggability matter in production, the curriculum contrasts make_shared with direct new, explains allocation and layout implications, and highlights differences observed across MSVC, GCC, and Clang. Ownership patterns are the capstone: when and how to use shared ownership, where weak_ptr fits, how to model temporary borrowing safely, and how to break cycles in graphs, observers, and caches. The end result is confidence: the ability to read, design, and refactor code that is leak‑free, exception‑safe, and maintainable—backed by small, runnable examples that make each concept stick.

Features

6-hrs On Demand Video

Exclusive 1-on-1 With Instructor

Course Completion Certificate

Priority Q/A

Full Lifetime Access

Community Access

Curriculum

Understand in detail on what is planned under each module

👨‍🏫 Course Introduction

📞 Exclusive 30-Minute Session

📊 Course Material

📄 Source Code

Introduction

std::shared_ptr Example

Reference Counting

Copy Semantics

Return Type

Arguments - I

Arguments - II

Arguments - III

Quiz

Uninitialized Pointers

Dangling Pointers

Memory Leaks - I

Memory Leaks - II

Containers

Polymorphism - I

Polymorphism - II

Multithreading - I

Multithreading - II

Quiz

Introduction to Control Block

Reference Counting Revisited

Deleter - I

Deleter - II

Managing File Pointer

Managing Win32 File Handle

Managing Win32 ATOM

Managing Dll Handle

Managing POSIX File Descriptor

More Complex Resource Management

Deleter Internals - I

Deleter Internals - II

C Runtime In Dll - I

C Runtime In Dll - II

C Runtime In Static Library

unique_ptr Across Dll Boundary

shared_ptr Across Dll Boundary

Dynamic Array - I

Dynamic Array - II

Conventional Construction - MSVC

Conventional Construction - GCC & Clang

Introducing std::make_shared

std::make_shared Construction

Control Block - I

Control Block - II

Control Block Layout

Ownership Concepts

Shared Ownership - I

Shared Ownership - II

Weak Ownership - I

Weak Ownership - II

Weak Count - I

Weak Count - II

Acquiring Temporary Ownership - I

Acquiring Temporary Ownership - II

Acquiring Temporary Ownership - III

Cyclic Dependency - I

Cyclic Dependency - II

Cyclic Dependency - III

Cyclic Dependency - IV

Using make_shared & weak_ptr - I

Using make_shared & weak_ptr - II

Using make_shared & weak_ptr - III

Course Completion Certificate

Why Do This Course

Diagnose and eliminate memory leaks, dangling references, and ownership cycles in real projects

Refactor legacy raw-pointer code to robust, maintainable smart‑pointer architectures

Pass, return, and store shared_ptr in APIs and STL containers with correct value/reference semantics

Get a deep insight of inner working of shared_ptr, deleters & weak_ptr

Requirements

  • Basic knowledge of C++
  • Modern C++ compiler (Visual Studio 2022, gcc 13, clang 17)

Related Products

Additional products that may be relevant to your interests

Image23

Instructor


- Hello! I'm Umar Lone

I've educated and mentored students and professionals globally, leveraging over 20 years of experience in C++, Object-Oriented Programming, Design Patterns, and related technologies. My professional background includes significant contributions to C++, Java, and C# projects with esteemed companies, alongside providing specialized project consultation & mentoring.


My current focus is on delivering comprehensive video courses that distill this extensive knowledge. I specialize in transforming intricate concepts into clear, practical, and actionable insights, supported by real-world examples. This approach is designed to equip you with the necessary clarity and confidence for sustained growth and impactful contributions within your projects and career trajectory.


Begin your learning journey with me now and unlock the advanced understanding and practical expertise essential for making a significant impact in your field.


Keep in touch

Subscribe for announcements, new courses & discount coupons

Yes please, save my details so you can send me educational content that is relevant and helpful.