0

I followed the steps outlined here to find memory leaks in a C++ program that I compiled using -g, but the program never terminates, and thus the memory leaks check doesn't end.

Whereas by using the same C++ program this time compiled using -Os the valgrind check terminates.

What can I do then?

  • `-g` is independent from `-Os`, compile with both. Also `-g` should only add debug informations, so it should not change the behaviour of the program. – mch Mar 27 '17 at 09:27
  • @mch But then why does the valgrind check not terminate with `-g`? – John Donym Mar 27 '17 at 09:31
  • Does the `-g` program terminate without valgrind? – mch Mar 27 '17 at 09:39
  • @mch No, but when compiled without `-g` it does terminate with valgrind. What can I do in such case? – John Donym Mar 27 '17 at 09:45
  • If changing compiler flags and/or running under valgrind changes behaviour, there's probably a bug. You need to figure out what that is first anyway, so try using the debugger. Just attach gdb to your non-terminating `-g` process without using valgrind. – Useless Mar 27 '17 at 09:48

0 Answers0