Boost logo

Boost :

From: Larry Evans (jcampbell3_at_[hidden])
Date: 2002-09-02 14:35:24

Philippe A. Bouchard wrote:

>Philippe A. Bouchard wrote:

>... and placement operator new (size_t, gc_type const &) could clean the
>garbage in the heap if malloc() returns 0 also.
I think the main difference is I would recommend reusing the code developed
by the "conservative garbage collectors". This code delays the freeing
until some criteria is met (such as malloc returning null), then it
it's garbage collection. However, as you've mentioned before, it doesn't
know about c++ destructors, unless they are something like Boehm's
finalizers (see
However, this would not be needed because, with rc, the finalizers
(i.e. ~T() ) are run when get_count() == 0. OOPS. Except when there are
cycles in the pointer graph :(. The only way around this is possibly to
this problem during the conservative garbage collection and issue a warning.
This wouldn't cause any bugs, it would just waste space, and the programmer
could eventually track down the cycle and correct it by making the closing
of the cycle a weak pointer (like Greg/Beman/Peter's weak_ptr). Also, if
the programmer were really paranoid about cycles, he could cause any
assignment to check whether the assignment produced a cycle. Also, the
collection could be made precise instead of conservative by using some
variation Greg's cyclic_ptr algorithm.

Boost list run by bdawes at, gregod at, cpdaniel at, john at