News for hackers. Stuff that matters.
Re:Three kinds of memory leaks by banachtarski on Tuesday May 01, 2018 @03:29AM (#16965187)
[referring to unreachable allocations]

> If you’re writing in C or C++, especially C++ without ubiquitous use of smart pointers to manage memory lifetimes, this is your first guess.

What absolute rubbish. Ever heard of a constructor/destructor (aka RAII)? You can go really far without the usage of any new/delete or a smart pointer, and this probably should be the case all the way up till the OS boundary.

Re:Three kinds of memory leaks by quietbritishjim on Tuesday May 01, 2018 @04:35AM (#16965419)
Responding to a suggestion to use smart pointers with a suggestion to RAII instead doesn't make sense because smart pointers are themselves an example of RAII. I assume what you meant was using stack allocations to avoid heap allocations except (presumably) via library containers like the STL.

This is a good idea where it can be done, and it's worth noting that move semantics replace some uses where a unique pointer would've have been necessary pre-C++11. But there are plenty of applications where it's really not possible. A big one is that if you're using inherence and virtual methods (out of fashion though they are) then you'll almost certainly need a pointer. Plenty of large complex applications cannot avoid object lifetimes with complex rules, which shared pointers track nicely, usually because objects are shared between threads or network requests. For example, if you're using ASIO (which is the basis of standard library networking in C++20) it's hard to imagine how you'd avoid using shared pointers.

Re:Three kinds of memory leaks by geofft on Tuesday May 01, 2018 @01:15PM (#16969035)
How do you implement a tree or a linked list without using new/delete or smart pointers?
Re:Three kinds of memory leaks by golergka on Tuesday May 01, 2018 @04:24AM (#16965377)
Most of the time, RAII is a good idea. Not always, though.

https://www.google.ru/url?sa=t&source=web&rct=j&url=%23&ved=...

(Sorry for weird url, YouTube seems to be currently blocked here and I'm too lazy to wait for a VPN connection).

Re:Three kinds of memory leaks by chrismorgan on Tuesday May 01, 2018 @04:46AM (#16965445)
That URL doesn’t work at all—just redirects to #.
Re:Three kinds of memory leaks by golergka on Tuesday May 01, 2018 @05:18AM (#16965557)
It was to Jonathan's Blow presentation for ideas about a language for game programming, where he goes in depth about RAII, C/C++, Go, Rust and other modern language developments.