0

I have a c++ code and I am checking the memory leak via valgrind. The result is as follows:

==== LEAK SUMMARY:
====    definitely lost: 0 bytes in 0 blocks
====    indirectly lost: 0 bytes in 0 blocks
====      possibly lost: 5,068,885 bytes in 341 blocks
====    still reachable: 0 bytes in 0 blocks
====         suppressed: 0 bytes in 0 blocks
==== 

I have read about the "possibly lost" case in the manual, but I am not sure if it is a big problem. Do you know what can cause this lost? Where should I check in my code to eliminate it? Is it a good action to leave as is?

Thanks

user2147241
  • 53
  • 1
  • 9
  • This answer would probably help you: http://stackoverflow.com/questions/3537713/valgrind-can-possibly-lost-be-treated-as-defintely-lost – Pedrom Jan 08 '14 at 20:26

1 Answers1

0

Possibly lost means your program is leaking memory unless you're doing clever (read: strange) things with pointers like pointing to the middle of a memory block.

If you deem your code "leak free" and want to suppress this warning, you can use the option --show-possibly-lost=no.

More information can be found here valgrind "possibly lost"

Community
  • 1
  • 1
Tyler Jandreau
  • 4,245
  • 1
  • 22
  • 47
  • IMHO - It is not a good idea to suppress errors. Why not fix them? – Ed Heal Jan 08 '14 at 20:36
  • @EdHeal I wasn't advocating suppressing the warning. Just showing the OP that he/she could if they wanted. I see what you mean, though, I'll edit the answer. – Tyler Jandreau Jan 08 '14 at 20:38
  • Is there any commands to see where the leak actually occurs? – user2147241 Jan 08 '14 at 20:42
  • @user2147241 - why not read the code? – Ed Heal Jan 08 '14 at 21:02
  • @EdHeal I have been doing some work and modifications on the code but still I see the leak. I suspect the reason is because of pointer usage in the code, and trying to figure out why the leak occurs. In the leak report, it says: 1,048,784 bytes in 1 blocks are possibly lost in loss record 116 of 116, and some more similar things. I am not sure if these can help me find where it occurs. Thanks for your help for my issue. – user2147241 Jan 08 '14 at 21:21