1

My valgrind always says that I'm allocating a lot of stuff even though i'm not. I just did a main that returned 0 and ran valgrind, it returned this. I have just reset my computer.

I don't know if it makes any difference but I'm using a mac Yosemite, but it was happening on the El Capitan as well and soon I'll test on the Sierra too. Is there anything I can do to zero the "allocs" and the "definitely lost" on valgrind? With a log like this I never know if I'm freeing everything correctly

It is happening even when I do not include any libraries

==11011== HEAP SUMMARY:
==11011==     in use at exit: 34,527 bytes in 414 blocks
==11011==   total heap usage: 514 allocs, 100 frees, 41,503 bytes 
allocated
==11011== 
==11011== LEAK SUMMARY:
==11011==    definitely lost: 16 bytes in 1 blocks
==11011==    indirectly lost: 0 bytes in 0 blocks
==11011==      possibly lost: 0 bytes in 0 blocks
==11011==    still reachable: 0 bytes in 0 blocks
==11011==         suppressed: 34,511 bytes in 413 blocks
Semar Augusto
  • 57
  • 1
  • 7
  • Possible duplicate of [Valgrind: Memory still reachable with trivial program using ](http://stackoverflow.com/questions/30376601/valgrind-memory-still-reachable-with-trivial-program-using-iostream) – yoones Apr 28 '17 at 14:20

1 Answers1

0

I wouldn't worry about this - it's a small amount and probably system related. Concentrate on issues that the tool identifies in your code.

You may get more details if you turn on all of the memory leak options, something like

--memcheck:leak-check=full --memcheck:show-reachable=yes
--memcheck:show-possibly-lost=yes --memcheck:track-origins=yes --verbose
Paul Floyd
  • 5,530
  • 5
  • 29
  • 43
  • It's less about the amount of memory lost than the ability to monitor his own memory consumption and potential memory leaks. I think he's right in wanting to have a clean base uppon which he'll write his code. – yoones Apr 28 '17 at 15:19
  • exactly, the problem is that this way i will not know if i'm allocating more than i'm freeing and things like that – Semar Augusto Apr 28 '17 at 15:23
  • Realistically what can you do about it? Get Apple to change macOS? Not likely. Get a fix in Valgrind. Maybe. As long as this is constant and small then it is not a worry. – Paul Floyd Apr 28 '17 at 15:32
  • It could be overhead to setup mach calls or possibly related to their dynamic linker. Even if you don't use any library, it's going to use libsystem and that's the kitchen sink including libc as well as many other things on OS X. – Lucas Holt Apr 28 '17 at 15:34
  • yeah, I ran valgrind using the --leak-check=full and you're right, Lucas Holt. It's on the libsystem. Do you know if there is anything I can do about it? – Semar Augusto Apr 28 '17 at 16:13