Information
We are currently investigating an issue with the editor of some pages. Please save your work and avoid to create new pages until this banner is gone.
I want to try to find memory leaks in my application. How would I use valgrind?
This quite easy as long as one rememebers the 40000 options.
Here is an example command line:
[tjuerges@delphinus ~]$ valgrind --leak-check=full --leak-resolution=high myProgram
Now, here is an example output (after the program exited):
==7958== ==7958== ==7958== 10244 bytes in 1 blocks are possibly lost in loss record 329 of 337 ==7958== at 0x1B904639: operator new[](unsigned) (vg_replace_malloc.c:138) ==7958== by 0x1BB5072C: TAO_ORB_Core::TAO_ORB_Core(char const*) (in /export/home/delphinus/alma/ACS-6.0/TAO/ACE_wrappers/build/linux/TAO/tao/libTAO.so.1.5.2) ==7958== ==7958== LEAK SUMMARY: ==7958== definitely lost: 1364 bytes in 33 blocks. ==7958== indirectly lost: 32005 bytes in 361 blocks. ==7958== possibly lost: 15600 bytes in 41 blocks. ==7958== still reachable: 610023 bytes in 4849 blocks. ==7958== suppressed: 0 bytes in 0 blocks. ==7958== Reachable blocks (those to which a pointer was found) are not shown. ==7958== To see them, rerun with: --show-reachable=yes
To find the possible locations of the memory leaks, one has to look through the output of valgrind. It might be a good idea to save the output to a file (see valgrind --help).
Good luck! -- ThomasJuerges - 19 Jan 2007