有没有静态分析工具可以帮助检测shared_ptr<>循环引用?

发布于 2024-09-25 03:26:48 字数 87 浏览 1 评论 0 原文

有没有静态分析工具可以帮助检测shared_ptr<>循环引用?

即使这样的工具无法检测复杂的情况,它对于消除简单的情况仍然很有用。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

不甘平庸 2024-10-02 03:26:48

不知道是否存在此类工具,但是这里有 关于这个问题的好想法:

有效的对象生命周期管理的关键
就是拥有一个非循环对象所有权图。
然后往下走的时候就用共享指针,
横向移动时指针较弱,
和弱指针(或有时是普通指针)向上移动时。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文