简单的Hello World C程序中的内存泄漏

时间:2016-09-17 22:50:52

标签: c memory-leaks valgrind

我是C的初学者,我想知道为什么这个简单的Hello World程序有内存泄漏:

 #include <stdio.h>
 int main(int argc, const char *argv[]) {
   printf("Hello world\n");
   return 0;
 }

它编译,但这是Valgrind报道的:

> valgrind ./a.out
==36468== Memcheck, a memory error detector
==36468== Copyright (C) 2002-2015, and GNU GPL'd, by Julian Seward et al.
==36468== Using Valgrind-3.12.0.SVN and LibVEX; rerun with -h for copyright   info
==36468== Command: ./a.out
==36468== 
Hello world
==36468== 
==36468== HEAP SUMMARY:
==36468==     in use at exit: 26,207 bytes in 190 blocks
==36468==   total heap usage: 264 allocs, 74 frees, 32,175 bytes allocated
==36468== 
==36468== LEAK SUMMARY:
==36468==    definitely lost: 0 bytes in 0 blocks
==36468==    indirectly lost: 0 bytes in 0 blocks
==36468==      possibly lost: 2,064 bytes in 1 blocks
==36468==    still reachable: 0 bytes in 0 blocks
==36468==         suppressed: 24,143 bytes in 189 blocks
==36468== Rerun with --leak-check=full to see details of leaked memory
==36468== 
==36468== For counts of detected and suppressed errors, rerun with: -v
==36468== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)

&#34;可能丢失的内容:1个块中的2,064个字节&#34;并且&#34;被抑制:189块中的24,143字节&#34;?我从未使用过malloc,所以我不确定为什么会这样。

0 个答案:

没有答案