[C++-sig] Re: Pyste feature: class member deletion order solution

David Abrahams dave at boost-consulting.com
Mon Nov 10 01:52:25 CET 2003


"Niall Douglas" <s_sourceforge at nedprod.com> writes:

> On 9 Nov 2003 at 14:19, David Abrahams wrote:
>
>> > I was thinking that the obvious solution is for representations of
>> > C++ objects to be able to hold a boost::python::handle<> of their
>> > parent, thus ensuring that the parent stays alive as long as its
>> > children. 
>> 
>> Won't help.  You'll have a reference cycle.  that have __del__()
>> methods and are part of a reference cycle cause the entire reference
>> cycle to be uncollectable, which will prevent the C++ object from
>> being destroyed.
>
> I can't see how that would happen. The bottom-most children (who 
> don't have any extra things holding a reference to them) when deleted 
> decrement the reference count of their parents. If a parent has no 
> other thing using it, it too gets deleted.

The children won't get deleted, because they are part of a reference
cycle.  Please think a bit more before arguing with me.

-- 
Dave Abrahams
Boost Consulting
www.boost-consulting.com





More information about the Cplusplus-sig mailing list