![](/img/trans.png)
[英]Valgrind reports “still reachable” bytes when using vfwprintf
[英]Valrind reports “still reachable” in empyt function
我正在使用valgrind检查我的C应用程序的内存使用情况。 在第一次测试后,valgrind报告:
"still reachable: 2,248 bytes in 1 blocks".
我检查了代码,但无法一眼发现问题。 因此,我开始注释代码的各个部分以尝试查找问题。
当我只剩下我的代码时,我感到震惊
int main(void)
{
};
和STILL会收到消息,唯一的区别是字节数。
我真的对此感到困惑...
这是完整的消息:
Running with options : valgrind --leak-check=full --show-reachable=yes
==2557== HEAP SUMMARY:
==2557== in use at exit: 2,248 bytes in 1 blocks
==2557== total heap usage: 362 allocs, 361 frees, 14,579 bytes allocated
==2557==
==2557== 2,248 bytes in 1 blocks are still reachable in loss record 1 of 1
==2557== at 0x4006171: calloc (vg_replace_malloc.c:593)
==2557== by 0x4D72250B: monstartup (in /usr/lib/libc-2.15.so)
==2557== by 0x8048650: __gmon_start__ (in /home/elias/Documents/SL_HTTP/Endosos/bin/Debug/Endosos)
==2557== by 0x4005421: ??? (in /usr/local/lib/valgrind/vgpreload_memcheck-x86-linux.so)
==2557==
==2557== LEAK SUMMARY:
==2557== definitely lost: 0 bytes in 0 blocks
==2557== indirectly lost: 0 bytes in 0 blocks
==2557== possibly lost: 0 bytes in 0 blocks
==2557== still reachable: 2,248 bytes in 1 blocks
==2557== suppressed: 0 bytes in 0 blocks
==2557==
==2557== For counts of detected and suppressed errors, rerun with: -v
==2557== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
Profiling timer expired
我正在Fedrora 17中使用gcc 4.7.2进行编译
任何建议将被认真考虑。 谢谢。
这完全可以并且可以忽略。 在这种情况下,这似乎是通过概要分析分配的内存(您可能是在启用概要分析的情况下编译代码或链接到具有此功能的某些库)。
您的环境在调用main
之前会做很多事情来设置,这些事情可以分配内存。 因为他们知道在程序退出之前将一直使用此内存,所以他们不必费心在退出时free
它,因为这只会花费时间,没有任何好处。 valgrind将把大部分内存报告为“仍可访问”,可以放心地忽略它们。
谢谢大家。
你是对的。
我正在使用Code:Blocks 12.11,默认情况下,它在编译器设置中启用了-pg。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.