我用命令运行valgrind:
valgrind --leak-check=full --show-leak-kinds=all --track-origins=yes
--max-stackframe=10485760 --log-file=valgrind_output.txt ./MyPrg
我用符号构建了我的可执行文件。
输出包括:
==30169== HEAP SUMMARY:
==30169== in use at exit: 72,704 bytes in 1 blocks
==30169== total heap usage: 688,466 allocs, 688,465 frees, 622,080,633 bytes
allocated
==30169==
==30169== 72,704 bytes in 1 blocks are still reachable in loss record 1 of 1
==30169== at 0x4C2DB8F: malloc (in /usr/lib/valgrind/
vgpreload_memcheck-amd64-linux.so)
==30169== by 0x4EC3EFF: ??? (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.21)
==30169== by 0x40106B9: call_init.part.0 (dl-init.c:72)
==30169== by 0x40107CA: call_init (dl-init.c:30)
==30169== by 0x40107CA: _dl_init (dl-init.c:120)
==30169== by 0x4000C69: ??? (in /lib/x86_64-linux-gnu/ld-2.23.so)
==30169== by 0x5: ???
==30169== by 0xFFF000242: ???
==30169== by 0xFFF000247: ???
==30169== by 0xFFF00024A: ???
==30169== by 0xFFF00024C: ???
==30169== by 0xFFF00024F: ???
==30169== by 0xFFF000252: ???
==30169==
==30169== LEAK SUMMARY:
==30169== definitely lost: 0 bytes in 0 blocks
==30169== indirectly lost: 0 bytes in 0 blocks
==30169== possibly lost: 0 bytes in 0 blocks
==30169== still reachable: 72,704 bytes in 1 blocks
==30169== suppressed: 0 bytes in 0 blocks
如何获取更多信息以找出与此可访问块相关的变量?
更新1
看起来其他人获得相同的输出:https://bugs.archlinux.org/task/45051
我正在使用Linux Mint 18.1。
更新2
使用gdb我得到输出:
[Inferior 1 (process 15499) exited normally]
答案 0 :(得分:1)
警告指向function encodeName(name){
var encName = encodeURIComponent(name);
encName = encName.replace(/'/g, '%27%27');
return encName;
}
第72行的分配:
var fileName = encodeName("Test ' ");
我不认为,这是代码中的问题,而是动态库加载器。有关详细信息,请参阅此答案:c++ valgrind shows memory leak in hello world
根据bug report,它在gcc 6中修复。当我使用gcc 7.2.1和clang 5.0.1进行测试时,我也没有得到valgrind警告。