I'm just starting to try out Valgrind, and as a control, I ran it on a trivial C file and got unexpected results. Here are the contents of blank.c
:
int main() {
return 0;
}
I compiled with gcc -o blank blank.c
I ran valgrind --tool=memcheck ./blank
and got this output:
==7877== Memcheck, a memory error detector
==7877== Copyright (C) 2002-2015, and GNU GPL'd, by Julian Seward et al.
==7877== Using Valgrind-3.11.0 and LibVEX; rerun with -h for copyright info
==7877== Command: ./blank
==7877==
==7877==
==7877== HEAP SUMMARY:
==7877== in use at exit: 22,177 bytes in 185 blocks
==7877== total heap usage: 267 allocs, 82 frees, 28,377 bytes allocated
==7877==
==7877== LEAK SUMMARY:
==7877== definitely lost: 0 bytes in 0 blocks
==7877== indirectly lost: 0 bytes in 0 blocks
==7877== possibly lost: 0 bytes in 0 blocks
==7877== still reachable: 0 bytes in 0 blocks
==7877== suppressed: 22,177 bytes in 185 blocks
==7877==
==7877== For counts of detected and suppressed errors, rerun with: -v
==7877== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
I don't understand why the Heap Summary shows so much memory in use and so many allocs when my program doesn't do anything. How do I understand/fix this?
I'm not sure what other information would be helpful, but gcc --version
returns
Configured with: -- prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 7.0.2 (clang-700.1.81)
Target: x86_64-apple-darwin15.3.0
Thread model: posix
---EDIT--- Like the other question which this one duplicates, if I run my trivial C program on a Linux machine, everything looks clean and pretty.