当 valgrind 说没有内存泄漏时,内存泄漏的可能性
使用 valgrind 检查时,我的 C 代码没有显示任何内存泄漏。但是当我将该代码与另一个系统集成时,该系统有自己的内存管理,但当然调用 malloc
来分配内存,显示内存泄漏。 Valgrind 检查过去每次都是正确的,但这次对我不起作用。我想知道是否存在内存泄漏的可能性,尽管 valgrind 说没有内存泄漏。为了找到最难的内存泄漏,可以设置哪些 valgrind 的最强参数?
My C
code does not show any memory leak while checking with valgrind. But when i integrate that code with another system, which has its own memory management but of course calls malloc
for allocating memory, shows memory leak. Valgrind check used to be correct everytime, but this time its not working for me. I would like to know if there is chances of memory leak although valgrind
says no memory leak. What can be the strongest parameters of valgrind to set to find the hardest memory leak?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为您很可能仍然存在内存泄漏 - 不是因为我认为 valgrind 有错误,而是因为我认为将其与另一个项目集成可能会以与您的测试不同的方式执行代码。 (仅供参考 - 我还没有发现任何内存泄漏的情况,valgrind 说我的代码很清楚,尽管这并不是详尽的证据)。我认为为了解决这个问题,要么向未集成的版本添加测试,要么在 valgrind 中运行集成版本。
其他选项可能会确保您不会抑制任何可能有害的错误,添加 --leak-check=full 或以其他方式使用 valgrind 设置。
I think it's very possible that you still have a memory leak - not because I think that valgrind has bugs, but because I think that integrating it with another project probably exercises the code differently than your test does. (FYI - I haven't found any cases of memory leaks where valgrind says my code is clear, although that's hardly exhaustive proof). I think in order to solve the problem is to either add tests to your un-integrated version or to run the integrated version in valgrind.
Other options might be making sure you're not suppressing any errors that could be harmful, add --leak-check=full, or otherwise play with your valgrind setup.