🧠C++ Memory Management Basics
Trade segfaults and double-frees for ownership you can reason about. By drop 14 you'll ship a small RAII resource wrapper that handles exceptions without leaking — and you'll know exactly why unique_ptr is the default and shared_ptr the exception.
Phase 1The Cost of Manual Memory
Stack, heap, and the real cost of manual memory
Your variables live in two completely different worlds
6 minYour variables live in two completely different worlds
Every `new` is a promise, and you owe a `delete`
6 minEvery `new` is a promise, and you owe a `delete`
The bug isn't the leak — it's the path you didn't see
7 minThe bug isn't the leak — it's the path you didn't see
Wrap the resource in an object and let scope do the work
7 minWrap the resource in an object and let scope do the work
Phase 2Smart Pointers in Practice
Swap raw pointers for unique_ptr and shared_ptr
One owner, no exceptions — that's `unique_ptr`
7 minOne owner, no exceptions — that's `unique_ptr`
Shared ownership has a price tag — read it before you swipe
7 minShared ownership has a price tag — read it before you swipe
Break the cycle with a pointer that doesn't own
7 minBreak the cycle with a pointer that doesn't own
Smart pointers don't only manage `delete` — they manage anything
8 minSmart pointers don't only manage `delete` — they manage anything
Three smart pointer mistakes that look right and aren't
7 minThree smart pointer mistakes that look right and aren't
Phase 3RAII, Moves, and Exception Safety
Wire RAII to destructors, moves, and exception safety
Your service leaks file handles. The `new` is fine. What's wrong?
7 minYour service leaks file handles. The `new` is fine. What's wrong?
You inherit a function returning `vector<Big>` by value. The reviewer says it's slow. Is it?
8 minYou inherit a function returning `vector<Big>` by value. The reviewer says it's slow. Is it?
Your wrapper class works in tests and double-frees in production. Why?
8 minYour wrapper class works in tests and double-frees in production. Why?
Code review asks for 'strong exception safety.' What does that even mean?
8 minCode review asks for 'strong exception safety.' What does that even mean?
Phase 4Build an Exception-Safe Wrapper
Build an exception-safe resource wrapper from scratch
Build a `FileBuffer` class that handles every exception path correctly
25 minBuild a `FileBuffer` class that handles every exception path correctly
Frequently asked questions
- When should I use unique_ptr versus shared_ptr in C++?
- This is covered in the “C++ Memory Management Basics” learning path. Start with daily 5-minute micro-lessons that build from fundamentals to hands-on application.
- What is RAII and why does C++ depend on it?
- This is covered in the “C++ Memory Management Basics” learning path. Start with daily 5-minute micro-lessons that build from fundamentals to hands-on application.
- Why is `new`/`delete` discouraged in modern C++?
- This is covered in the “C++ Memory Management Basics” learning path. Start with daily 5-minute micro-lessons that build from fundamentals to hands-on application.
- How do move semantics interact with smart pointers?
- This is covered in the “C++ Memory Management Basics” learning path. Start with daily 5-minute micro-lessons that build from fundamentals to hands-on application.
- What makes a class exception-safe in C++?
- This is covered in the “C++ Memory Management Basics” learning path. Start with daily 5-minute micro-lessons that build from fundamentals to hands-on application.
Related paths
🐍Python Decorators Introduction
Build one mental model for Python decorators that covers closures, argument passing, functools.wraps, and stacking — then ship a working caching or logging decorator from scratch in under 30 lines.
🦀Rust Lifetimes Explained
Stop reading `'a` as line noise and start reading it as scope arithmetic — one failing snippet at a time — until you can thread lifetimes through a small parser or iterator adapter without fighting the borrow checker.
☸️Kubernetes Core Concepts
Stop drowning in 30+ resource types. Build the mental model one primitive at a time -- pods, deployments, services, ingress, config -- then deploy a real app with rolling updates and health checks.
📈Big O Intuition
Stop treating Big O as math you memorized for an interview — build the intuition to spot O(n²) disasters, pick the right data structure without thinking, and rewrite a slow function from O(n²) to O(n) in under five minutes.