Subject: Re: [boost] Review of a safer memory management approach for C++?
From: Mathias Gaunard (mathias.gaunard_at_[hidden])
Date: 2010-05-27 08:56:38


Bartlett, Roscoe A wrote:
> Hello Boost developers,
>
> I am interested in finding one or more individuals who are knowledgeable about memory management in C++ (and especially of the reference-counting approach taken by boost::shared_ptr and boost::weak_ptr) to review an idea for a comprehensive approach to safer memory management in C++ that encapsulates all raw C++ pointers in high-level code.

Never use owning naked pointers and only use RAII (as is required for
exception-safe programming anyway) with exclusive ownership and no
aliasing, and you have no problems.

Usage of shared_ptr should be an exception, not a widely deployed
solution to memory management issues.
Shared ownership is hard to reason about, and even if you use a similar
cycle-aware solution, cycles remain a real problem (they prevent
deterministic ordered destruction of objects, meaning they're only
applicable to certain classes of objects).