
12 Nov
2004
12 Nov
'04
12:06 a.m.
On 11/11/2004 12:40 PM, Peter Dimov wrote: [snip]
With that you can build the reference graph to detect the cycles.
Except that you can't. :-)
struct X { std::vector<Y> v_; };
If Y has shared_ptr instances that refer back to X, this is untraceable, because the tracer doesn't know that it should follow the pointer inside the std::vector.
Couldn't each stl container which contains (or might contain) a shared_ptr also be reflected (e.g. v_'s presence in X recorded in gc_desc<X> )? In this case, the cycle-finder could iterate through each Y in v_ to find any cycles.