|
Boost : |
From: Larry Evans (jcampbell3_at_[hidden])
Date: 2002-09-10 22:03:56
On Tue, 2002-09-10 at 20:27, Philippe A. Bouchard wrote:
> Larry Evans wrote:
>
> > On Tue, 2002-09-10 at 17:11, Philippe A. Bouchard wrote:
> >> I've cleaned up operator new()s and reference counts can now be mixed
> >> with garbage collectors:
> >> http://groups.yahoo.com/group/boost/files/ptr/
> >>
> >> Any comments are welcome.
> >>
> > I don't see any cycles in the pointer graph in placed_ptr_test.cpp.
>
> It's the following:
> {
> placed_ptr<node> pN = new (gc) node();
>
> pN->p = pN;
>
> pN.clear();
> }
>
> remove pN.clear() and the node will never be destructed (cout of ~node()).
>
OOPS. So obvious I missed it.
However, pN.clear() should NOT collect anything at the point it's
called above because pN.get() and pN->p.get() are both still "live".
In addition, clear should be a static method since it deals with
with all placed_ptr's, not just one. After exit from the {}, the static
collect() should be called to collect the "dead" objects.
A good definition of "live" and "dead" are at:
http://www.memorymanagement.org/glossary/
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk