
11 Nov
2004
11 Nov
'04
7:40 p.m.
Rene Rivera wrote:
A "faster" way to infer cycles for pointers could be done with a bit more information on the shared_ptr. If you keep a set of object memory spans (heap address, and class sizeof) for all shared instances you can find all shared_ptrs that fall within those shared instances.
See sp_collector.cpp.
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.