c++ 有哪些选项可用? OpenBSD 中的内存调试?

发布于 2024-11-30 09:25:21 字数 261 浏览 1 评论 0原文

我相信我在 OpenBSD 上的复杂 C++ 应用程序中以某种方式发生了双重删除和一些内存损坏。我想追踪我的对象被删除的第一个位置,以及访问已释放内存的任何点。

我通常会研究 valgrind,但它仅限于 Linux。如果做不到这一点,我会用某种跟踪代码来检测我的新操作符和删除操作符,但我发现很难确定正确的谷歌搜索。

openbsd 是否有任何软件包可以为我提供有关内存错误的信息?是否有任何标准方法可以重新定义 new 和 delete 来检测溢出、无效访问、双重释放?

I believe I have a double delete and some memory corruption happening somehow in my complex c++ application on OpenBSD. I would like to track down the first location my object is deleted, and any points at which deallocated memory is accessed.

I would usually look into valgrind, but it is linux only. Failing that, I would instrument my new and delete operators with some kind of tracking code, but I've been finding it difficult to determine the correct google search for this.

Is there any package for openbsd which will give me information on memory errors? Is there any kind of standard way to redefine new and delete to detect overflows, invalid accesses, double frees?

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

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

发布评论

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

评论(2

所有深爱都是秘密 2024-12-07 09:25:21

这很有帮助:

man malloc

调试选项可以在系统范围、环境范围或特定于程序的范围内启用。

This helps a lot:

man malloc

Debugging options can be enabled system-wide, environment-wide, or program-specific.

难得心□动 2024-12-07 09:25:21

我不知道你是否愿意使用第三方工具,但是C++内存验证器非常好。

http://www.softwareverify.com/cpp-memory.php

它隔离内存/ 处理泄漏,告诉您泄漏了多少内存并显示代码中的位置。如果它能为您修复泄漏就好了:) 还提供 30 天免费试用。

我用它来查找遗留 C++ MFC 应用程序中的泄漏,以前的开发人员似乎并不认为需要释放内存!

I don't know if you are willing to use a third party tool, but C++ memory validator is very good.

http://www.softwareverify.com/cpp-memory.php

It isolates the memory/ handle leaks, tells you how much memory is leaked and shows you the position in the code. If only it could then fix the leak for you : ) 30 day free trial is available too.

I've used it to find leaks in my legacy C++ MFC application where the previous developer didn't seem to think there was a need to relase memory ever!

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