views:

46

answers:

1

Are there any static analysis tools that can help detect shared_ptr<> circular references?

Even if such a tool couldn't detect complicated cases, it would still be useful for eliminating the simple cases.

+3  A: 

Don't know about existing of such tools, but here are nice thoughts about the problem:

The key to effective object life time management is to have an acyclic object ownership graph. Then you use shared pointers when going down, weak pointers when going sideways, and weak pointers (or sometimes plain pointers) when going up the graph.

Kirill V. Lyadvinsky
Nice lucid description of the solution.
John Dibling