加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

Valgrind C文件中的内存泄漏

发布时间:2020-12-16 05:48:46 所属栏目:百科 来源:网络整理
导读:我在valgrind中有一个“额外的”内存泄漏的问题.例如,我创建了一个名为temp.cpp的测试程序: int main() { return 0; } 在终端,我跑: g++ -o temp.out temp.cpp valgrind --tool=memcheck --leak-check=full --show-leak-kinds=all ./temp.out 这会导致几个
我在valgrind中有一个“额外的”内存泄漏的问题.例如,我创建了一个名为temp.cpp的测试程序:
int main() { return 0; }

在终端,我跑:

>> g++ -o temp.out temp.cpp
>> valgrind --tool=memcheck --leak-check=full --show-leak-kinds=all ./temp.out

这会导致几个内存泄漏.这怎么可能?

==4438== LEAK SUMMARY:
==4438==    definitely lost: 4,120 bytes in 2 blocks
==4438==    indirectly lost: 2,288 bytes in 6 blocks
==4438==      possibly lost: 8,336 bytes in 99 blocks
==4438==    still reachable: 6,440 bytes in 13 blocks  
==4438==         suppressed: 5,020 bytes in 73 blocks

我尝试运行其他.cpp文件,我得到完全相同的泄漏汇总.大约一个月前,当我试过,没有什么是错的.我可能会升级Xcode或某些东西,如果这可能是问题(?).这些是我的g设置:

配置为:

--prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/include/c++/4.2.1

Apple LLVM版本6.1.0(clang-602.0.53)(基于LLVM 3.6.0svn)
目标:x86_64-apple-darwin15.0.0
线程模型:posix

解决方法

在MacOSX上似乎valgrind有问题.虽然这些问题尚未解决,但可能的临时解决方案是使用抑制文件.详情请浏览 this other answer

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读