generating suppressions for memory leaks
Asked Answered
K

4

9

I want suppress Valgrind's reporting of some "definitely lost" memory by the library I'm using. I have tried valgrind --gen-suppressions=yes ./a but it only prompts for errors such as "conditional jump or move depends on uninitialized value".

Is there a way to generate suppressions for straight-up memory leaks? If not, is it difficult to write them by hand? Valgrind's manpage seems to discourage it, at least for errors.

Kisser answered 18/6, 2013 at 2:12 Comment(0)
P
9

Run valgrind with the --gen-suppressions=all and --log-file=memcheck.log options, and manually copy/paste the logged suppressions into the suppression file.

valgrind --leak-check=full --gen-suppressions=all --log-file=memcheck.log ./a 

If you find the output is mixed with the application output then redirect valigrind output to separate file descriptor: --log-fd=9 9>>memcheck.log

valgrind --leak-check=full --gen-suppressions=all --log-fd=9 ./a  9>>memcheck.log
Pleasantry answered 11/2, 2018 at 11:8 Comment(1)
The trick to separate valgrind's output from the application is super useful, thanks !Erector
K
4

To be prompted for leaks that aren't generating errors, you have to run

valgrind --leak-check=full --gen-suppressions=yes ./a 
Kisser answered 18/6, 2013 at 20:44 Comment(0)
I
0

There is a page on how you can generate such a file based on your errors https://wiki.wxwidgets.org/Valgrind_Suppression_File_Howto

It's not perfect, but you can start from it

Ingratitude answered 17/3, 2021 at 13:7 Comment(0)
B
-2

You can write a suppression file of your own (but it doesn't seem obvious) :

--suppressions=<filename> [default: $PREFIX/lib/valgrind/default.supp]

If the question was to disable an entire library, see this.

Valgrind's man page.

Birt answered 18/6, 2013 at 20:51 Comment(1)
The --suppressions option is required to read suppression file, not writePleasantry

© 2022 - 2024 — McMap. All rights reserved.