是否有任何静态分析工具可帮助检测shared_ptr 循环引用?即使这样的工具无法检测到复杂的案例,它对于消除简单案例仍然很有用。 (adsbygoogle = window.adsbygoogle || []).push({}); 最佳答案 不知道这些工具的存在,但是here are对这个问题有很好的想法: 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. (adsbygoogle = window.adsbygoogle || []).push({}); 09-17 21:02