Reputation: 884
I run valgrind version 3.12.0 from the console like this:
valgrind --log-file="valgrind.log" --leak-check=yes ./application -param
The log seems to be polluted while the application is running which is interesting already because I don't think that a memory leak can be detected with 100% certainty while the application is still running. I guess that in some scenarios (maybe threads) this is not true and valgrind is clever enough to catch those early on?
What really bothers me is that there are multiple "leak summaries" which contain more or less the same information. It seems to me that summaries logged at later stages contain more information.
Below you will find an output of valgrind executed on my Qt application. I used Notepad to list all "definitely" lost entries. You can see that there are tons of leak summaries and I don't know why the contained information is almost the same. Especially the 15 bytes leaked from the constructor of the QApplication is very strange since it is contained in every summary again and again. How does valgrind decide when to create such a summary?
Upvotes: 1
Views: 912
Reputation: 6936
One of the design goals of Valgrind is to not produce false positives (i.e., never incorrectly indicate a problem). On the whole it comes very close to this. Almost certainly you have a leak. I recommend that you do a debug build and look at the source code backreferences to debug the issue.
Leak detection is normally done when the application terminates. There are ways of triggering leak reports earlier:
leak_check
VALGRIND_DO_LEAK_CHECK
(there are several similar commands)Possibly you are using the second of these.
Lastly, 'almost the same' means that they are different. You could reduce the stack depth, which would make it more likely that callstacks will be grouped together.
During execution, Valgrind will output non-leak errors as they occur.
On termination, Valgrind outputs:
Upvotes: 1