CppCon 2016: Herb Sutter “Leak-Freedom in C++... By Default.”

Channel:CppCon · Length:1:39:25 · Published:2016-09-26 · Views:149280

Watch on YouTube

Summary

Herb Sutter's CppCon 2016 talk on lifetime safety in C++, aiming for code free of leaks and dangling pointers by default. It covers smart pointers, ownership, reference counting pitfalls and deferred reclamation resembling garbage collection.

Why HN recommends it

HN cites it in memory management debates for its treatment of reference counting problems, destructor stack overflows and deferred pointers.

Check all of Herb Sutter's CppCon videos from 2015-2016, especially this one — HN, 2016

C, C++, Rust, Go & systems languages

Subtitles (excerpt)

first of all thank you everybody for coming to this conference we had record attendance again this year it has been a blast I've heard from many of you how much you've enjoyed all the Keynotes and plenaries all the sessions so I'm going to try very hard not to let you down here near the end we're going to talk about leak freedom in C++ and we're not actually all that used to leaks in modern c+s because we know how to have objects own things but it's worth putting in one place for two reasons first of all I would like there to be a talk that people can link to that says yeah this is how you do it in C++ that seems relatively simple so we're going to start with the rules on one slide but then goes through example after example of how to apply them and acknowledge where we still need to be aware of issues and how to resolve them so that's how we're going to progress through the talk this is related to last year because last year be strip gave a a great introduction to the C++ core guidelines I specifically gave a talk that was on half of Lifetime safety about dangling pointers and we're still very interested in that we're in the process of writing down the formal specification rules so those can be implemented in analyzers

On Hacker News

Check all of Herb Sutter's CppCon videos from 2015-2016, especially this one: [VIDEO] He does a great job of walking through the thought process of deciding which of the options makes sense in different situations. — shermanyo, 2016-09
On single core without threading. If you add multi-threading and multi-core, there is lock contention for every single memory access to update the related counter. Additionally, if there is a big data structure in use, reaching zero will trigger a cascade deletion events reaching stop-the-world like effect. Which, depending on how the deletion was implemented, might trigger a stack overflow in ve… — pjmlp, 2020-01
Herb Sutter has a nice talk about how RAII can cause stack overflows or stop-the-world pauses if used badly. [VIDEO] — pjmlp, 2019-01
Reference counting isn't deterministic in the presence of large complex data structures. You will know when memory gets deleted, but not how long it will take, nor how much stack space the destructors will require to run. Enjoy Herb Sutter's "Leak-Freedom in C++... By Default." at CppCon 2016, where he explains how those issues affect C++ and goes on to implement a tracing GC. [VIDEO] — pjmlp, 2017-08
Herb Sutter gave a really great talk on this: [VIDEO] He has 3 guidelines: 1. Prefer scoped lifetimes by default (local members) 2. Else prefer unique_ptr and containers 3. Else consider shared_ptr His whole talk gives examples that show the flexibility of unique_ptr and how modern C++ can express ownership. See slide 5 here: [LINK] — shermanyo, 2016-09

Related videos