HackerTube

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

CppCon2 HN recommenders · recommended in 4 months, 2016–2025
YouTube
talk · advanced · evergreen · 2016–2025 on HN

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.

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

12 comments from Hacker News

@shermanyo2016-09 · in “Smart pointers and move semantics in modern C++”

Check all of Herb Sutter's CppCon videos from 2015-2016, especially this one: ▶ this video He does a great job of walking through the thought process of deciding which of the options makes sense in different situations.

Strongly recommends View on HN
@pjmlp2020-01 · in “Show HN: A pure reference counting GC in Go”

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 very deep structures. Herb Sutter has a very interesting talk about the bad issues of reference counting and how to work around them. CppCon 2016: Herb Sutter “Leak-Freedom in C++... By Default.” ▶ this video There are multiple ways to optimize reference counting, like deferred counting, cycle collectors and a couple of others, which when you are done with all them, ends up being quite similar to having a tracing GC anyway.

Recommends View on HN
@pjmlp2019-01 · in “Fearless Security: Memory Safety”

Herb Sutter has a nice talk about how RAII can cause stack overflows or stop-the-world pauses if used badly. ▶ this video

Recommends View on HN
@pjmlp2017-08 · in “Lazarus – A Delphi-compatible cross-platform IDE”

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. ▶ this video

Recommends View on HN
@shermanyo2016-09 · in “Smart pointers and move semantics in modern C++”

Herb Sutter gave a really great talk on this: ▶ 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

Recommends View on HN