From: "Larry Evans" <[EMAIL PROTECTED]> > > 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. > Would false positives be any less frequent than in the BW conservative collector?
BW = Boehm-Weiser? AFAIK BW false positives happen when a memory location resembles a valid heap address, and are much more likely. > Why not use the Delef approach as demonstrated in shared_cyclic_ptr to avoid > false positives altogether? I'm not familiar with Detlef's approach... does it require programmer support? > > Plain pointers would have to be followed by a real collector, but why should > > a "simple cycle-breaker" bother? > > > Because the following would require it in order to find the cycle: > > struc Y; > struct X > { > Y* y; //cyclic involves this arc. > }; > struct Y > { > boost::shared_ptr<X> x; > }; > > int main() > { > boost::shared_ptr<X> p1(new X); > boost::shared_ptr<X> p2(new X); > > p1->y.x = p2; > p2->y.x = p1; > > } This doesn't look correct to me... did you mean something like struct X { Y * p; explicit X(Y * p): p(p) {} ~X() { delete p; } }; struct Y { shared_ptr<X> p; }; int main() { Y * py = new Y; shared_ptr<X> px(new X(py)); py->p = px; px.reset(); } ? _______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost