1

I searched around but there seems no answers for me so I decided to ask here. So I used valgrind to check my program,here is the result

==24810== HEAP SUMMARY:
==24810==     in use at exit: 1,478 bytes in 30 blocks
==24810==   total heap usage: 50 allocs, 20 frees, 43078 bytes allocated
==24810== 
==24810== LEAK SUMMARY:
==24810==    definitely lost: 0 bytes in 0 blocks
==24810==    indirectly lost: 0 bytes in 0 blocks
==24810==      possibly lost: 0 bytes in 0 blocks
==24810==    still reachable: 1,478 bytes in 30 blocks
==24810==         suppressed: 0 bytes in 0 blocks

Is that a leak? If so, what could be the reason?

andyz
  • 55
  • 10

2 Answers2

0

It isn't a true leak in that the 30 extra chunks that were allocated are still reachable. It appears that you failed to free some structures at the end of your program's run. Note that the run time libraries will sometimes leave a few allocated objects around at the end but this doesn't feel like one of those cases.

DrC
  • 7,528
  • 1
  • 22
  • 37
0

Not a leak, it just means that some blocks of memory are still reachable at termination. To look for true memory leaks look at "definitely lost" and "indirectly lost"

See this post: Still Reachable Leak detected by Valgrind

Community
  • 1
  • 1