Search code examples
cmemory-leaksvalgrindmemcheck

Valgrind claims there is unfreed memory. Is this bad?


Valgrind gives me the following leak summary on my code. However, I have freed all malloc'ed memory. Is this a bad thing, or is this normal? My program is in c.

==3513== LEAK SUMMARY:

==3513== definitely lost: 0 bytes in 0 blocks.

==3513== possibly lost: 0 bytes in 0 blocks.

==3513== still reachable: 568 bytes in 1 blocks.

==3513== suppressed: 0 bytes in 0 blocks.


Solution

  • The valgrind message still reachable: 568 bytes in 1 blocks. means that there was memory freed in your application which is still "reachable", which means that you still have a pointer to it somewhere. At shutdown, this probably means a global variable of some kind. However, since the number of bytes "definitely leaked" or "probably leaked" is zero, this condition is completely benign. Don't worry about it.