Question

I am doing some tests with Libgcrypt and when I use valgrind to check the memory usage there is 3,200 bytes in use at exit.

I have tried to use

valgrind --leak-check=full --track-origins=yes --show-reachable=yes ./my_program

But valgrind valgrind only complains about this line from my code:

version = gcry_check_version("1.5.0");

and valgrind about internal functions of Libgcrypt.

My test code is here: http://www.tiago.eti.br/storage/post2.c And I am using Libgcrypt 1.5.0 from Debian sid repository

It is a bug of Libgcrypt or am I doing anything wrong?

Was it helpful?

Solution

Not all libraries are perfectly careful to clean up all their resources. As long as some "permanent" allocations happen only once and are in use until the end of the program (for example for a version string), it is entirely possible that the library just never bothers to deallocate this.

Thus is the unfortunate reality of dealing with third-party libraries, and if it bothers you, you should make a suppression file for Valgrind with --gen-suppressions=all.

Bear in mind that "still reachable" memory is just "laziness", and not really a leak, since you never actually lost the allocation. A leak should be considered a true programming error, while still reachable, un-deallocated memory may or may not be a forgivable shortcut.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top