c++ 有哪些选项可用? OpenBSD 中的内存调试?
我相信我在 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这很有帮助:
调试选项可以在系统范围、环境范围或特定于程序的范围内启用。
This helps a lot:
Debugging options can be enabled system-wide, environment-wide, or program-specific.
我不知道你是否愿意使用第三方工具,但是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!