C++ Valgrind即使在删除操作后仍显示泄漏
我有一个非常简单的程序如下:C++ Valgrind即使在删除操作后仍显示泄漏,c++,valgrind,C++,Valgrind,我有一个非常简单的程序如下: #include<iostream> using namespace std; int main() { char *s=new char[10]; cin>>s; cout<<s; delete[] s; } 编辑2:添加Valgrind错误/堆摘要报告: ==42891== LEAK SUMMARY: ==42891== definitely lost:
#include<iostream>
using namespace std;
int main()
{
char *s=new char[10];
cin>>s;
cout<<s;
delete[] s;
}
编辑2:添加Valgrind错误/堆摘要报告:
==42891== LEAK SUMMARY:
==42891== definitely lost: 20 bytes in 1 blocks
==42891== indirectly lost: 0 bytes in 0 blocks
==42891== possibly lost: 0 bytes in 0 blocks
==42891== still reachable: 528,598 bytes in 11,121 blocks
==42891== suppressed: 0 bytes in 0 blocks
==42891== Rerun with --leak-check=full to see details of leaked memory
==42891==
==42891== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
==42891== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
--42890-- REDIR: 0x52ead60 (libc.so.6:__GI_stpcpy) redirected to 0x4c2d8d0 (__GI_stpcpy)
--42890-- REDIR: 0x52e7590 (libc.so.6:__GI_strcpy) redirected to 0x4c2ab90 (__GI_strcpy)
--42890-- REDIR: 0x52e1450 (libc.so.6:realloc) redirected to 0x4c29aae (realloc)
--42890-- REDIR: 0x52eaf20 (libc.so.6:__GI___strcasecmp_l) redirected to 0x4c2b710 (__GI___strcasecmp_l)
test4.cpp: line 4: syntax error near unexpected token `('
test4.cpp: line 4: `int main()'
==42890==
==42890== HEAP SUMMARY:
==42890== in use at exit: 528,567 bytes in 11,123 blocks
==42890== total heap usage: 11,374 allocs, 251 frees, 570,897 bytes allocated
==42890==
==42890== Searching for pointers to 11,123 not-freed blocks
==42890== Checked 768,632 bytes
==42890==
==42890== LEAK SUMMARY:
==42890== definitely lost: 32 bytes in 1 blocks
==42890== indirectly lost: 24 bytes in 1 blocks
==42890== possibly lost: 0 bytes in 0 blocks
==42890== still reachable: 528,511 bytes in 11,121 blocks
==42890== suppressed: 0 bytes in 0 blocks
==42890== Rerun with --leak-check=full to see details of leaked memory
==42890==
==42890== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
==42890== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
g++(GCC)4.8.5 20150623(红帽4.8.5-11)
valgrind--版本valgrind-3.11.0真正的valgrind报告是否实际按行号调用了特定的行(main()中的第一行)?编译器?站台?Valgrind的完整报告?GCC 4.4.6已有8年历史。你能看看更新的版本吗?还有,Valgrind的版本是什么?好吧,现在这似乎是总结报告。这是完整的泄漏检查报告吗?这是你发布的报告中建议的,就在
错误摘要
部分的正上方。我甚至无法用GCC 4.8.5(Valgrind 3.15)复制它。您能否向我们展示整个程序(至少缺少标题,并且使用指令)以及您传递给std::cin
)的输入?real valgrind报告是否按行号实际调用了该特定行(main()
中的第一行)?编译器?站台?Valgrind的完整报告?GCC 4.4.6已有8年历史。你能看看更新的版本吗?还有,Valgrind的版本是什么?好吧,现在这似乎是总结报告。这是完整的泄漏检查报告吗?这是你发布的报告中建议的,就在错误摘要
部分的正上方。我甚至无法用GCC 4.8.5(Valgrind 3.15)复制它。您能给我们看一下整个程序的确切内容(至少缺少标题,并且使用指令),以及您要传递给std::cin
的输入吗?
==42891== LEAK SUMMARY:
==42891== definitely lost: 20 bytes in 1 blocks
==42891== indirectly lost: 0 bytes in 0 blocks
==42891== possibly lost: 0 bytes in 0 blocks
==42891== still reachable: 528,598 bytes in 11,121 blocks
==42891== suppressed: 0 bytes in 0 blocks
==42891== Rerun with --leak-check=full to see details of leaked memory
==42891==
==42891== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
==42891== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
--42890-- REDIR: 0x52ead60 (libc.so.6:__GI_stpcpy) redirected to 0x4c2d8d0 (__GI_stpcpy)
--42890-- REDIR: 0x52e7590 (libc.so.6:__GI_strcpy) redirected to 0x4c2ab90 (__GI_strcpy)
--42890-- REDIR: 0x52e1450 (libc.so.6:realloc) redirected to 0x4c29aae (realloc)
--42890-- REDIR: 0x52eaf20 (libc.so.6:__GI___strcasecmp_l) redirected to 0x4c2b710 (__GI___strcasecmp_l)
test4.cpp: line 4: syntax error near unexpected token `('
test4.cpp: line 4: `int main()'
==42890==
==42890== HEAP SUMMARY:
==42890== in use at exit: 528,567 bytes in 11,123 blocks
==42890== total heap usage: 11,374 allocs, 251 frees, 570,897 bytes allocated
==42890==
==42890== Searching for pointers to 11,123 not-freed blocks
==42890== Checked 768,632 bytes
==42890==
==42890== LEAK SUMMARY:
==42890== definitely lost: 32 bytes in 1 blocks
==42890== indirectly lost: 24 bytes in 1 blocks
==42890== possibly lost: 0 bytes in 0 blocks
==42890== still reachable: 528,511 bytes in 11,121 blocks
==42890== suppressed: 0 bytes in 0 blocks
==42890== Rerun with --leak-check=full to see details of leaked memory
==42890==
==42890== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
==42890== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)