Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2003-01-07 17:12:43


From: "Larry Evans" <jcampbell3_at_[hidden]>
> > 1. Find the two X objects (let's call them x1 and x2) on the heap, and
scan

> Wouldn't this scan have to be either conservative, like BW, or use some
way
> to determine the precise location of the shared_ptr's within, .e.g.
p1->get()?

Currently I use a conservative scan that assumes that shared_ptr instances
have a layout of

T * px;
counted_base * pi;
int id;

with pointers being aligned on a DWORD boundary. 'pi' must be in the count
map, and 'id' must be detail::shared_count::id. (It's possible to test 'px'
for validity too.) False positives should be extremely rare, but could not
be ruled out entirely, and hence, breaking cycles may potentially corrupt
the object.

> This scan will also have to follow plain pointers.

Plain pointers would have to be followed by a real collector, but why should
a "simple cycle-breaker" bother?


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk