C ++ - Valgrind on code blocks (linux)

I already use Valgrindin small programs to check memorys leaksand it works well.

Now I have a big program with many class and .cppand class files .h, and I'm trying to use Valgrindfor checking memory leakbecause I use a lot of pointers, memory, etc.

I use linuxboth codeblocks 16.01s gccand I try to run Valgrinddirectly in codeblocks, but I get the following error:

 --------------- Application output --------------
valgrind: /myPathToTheProject/ValgrindOut.xml: No such file or directory

If I test a small project only with a file .cppand it works well, it Valgrindgenerates ValgrindOut.xml. In this big project, I always get this error. Does anyone know what is wrong? or in another way or tool for testing memory leak?

EDIT - MAKE SUMMARY after running Valgrind

Leak summary:

definitely lost: 673 bytes in 6 blocks.
   indirectly lost: 89,128 bytes in 68 blocks.
     possibly lost: 232 bytes in 2 blocks.
   still reachable: 80,944 bytes in 6 blocks.
        suppressed: 0 bytes in 0 blocks.
+4
source share
1 answer

I am not sure how to run valgrind directly from code blocks. I suggest you create your project using code blocks. At run time, use valgrind as per the command below.

Team

valgrind --tool=memcheck --leak-check=full --show-leak-kinds=all --log-file=leak.txt ./myexecutable <my command line arguments>

Example

valgrind --tool=memcheck --leak-check=full --show-leak-kinds=all --log-file=leak.txt ./myexecutable -i 192.168.1.10 -p 5000

This way you can generate the valgrind output file, i.e. the leak.txt file containing memory leaks, etc.

0
source

Source: https://habr.com/ru/post/1682741/


All Articles