jeudi 14 février 2019

c++ valgrind memory leak ostream output

*Note: This is a homework assignment but it's quite late and I don't really have anyone to ask at this hour. Thanks :)

I am getting a valgrind memory leak from my code and I'm not exactly sure why or understand the output from valgrind.

I created this class that overloads the ostream operator (<<) and every time I try to output something using it I get a memory leak.

Like for example if I comment out the code to output it doesn't give me any memory leaks...

https://github.com/JacobAYoung/cs5201/tree/master/Homework2

I have posted my code up on github because I think it would be easier to look at that way instead of me pasting a bunch of code snippets.

I also posted the valgrind error message on pastebin: https://pastebin.com/4h9zp6PV

==20985== HEAP SUMMARY:
==20985==     in use at exit: 22,959 bytes in 169 blocks
==20985==   total heap usage: 214 allocs, 45 frees, 101,615 bytes allocated
==20985==
==20985== LEAK SUMMARY:
==20985==    definitely lost: 0 bytes in 0 blocks
==20985==    indirectly lost: 0 bytes in 0 blocks
==20985==      possibly lost: 72 bytes in 3 blocks
==20985==    still reachable: 4,444 bytes in 10 blocks
==20985==         suppressed: 18,443 bytes in 156 blocks
==20985== Rerun with --leak-check=full to see details of leaked memory
==20985==
==20985== For counts of detected and suppressed errors, rerun with: -v
==20985== Use --track-origins=yes to see where uninitialised values come from
==20985== ERROR SUMMARY: 10 errors from 3 contexts (suppressed: 1 from 1)

Aucun commentaire:

Enregistrer un commentaire