开发者

Valgrind complains while working with threads

开发者 https://www.devze.com 2023-02-17 04:50 出处:网络
I have created 20 threads to read/write a shared file.I have synchronized threads. Now My program works fine but when I run it with valgrind it gives me Errors like this:

I have created 20 threads to read/write a shared file.I have synchronized threads. Now My program works fine but when I run it with valgrind it gives me Errors like this:

LEAK SUMMARY:

   **definitely lost: 0 bytes in 0 blocks.
\
     **possibly lost: 624 bytes in 5 blocks开发者_如何学C.**

   **still reachable: 1,424 bytes in 5 blocks.****


    suppressed: 0 bytes in 0 blocks.

Reachable blocks (those to which a pointer was found) are not shown.

Also When I press Ctrl + c , it gives the same errors.

I have not even malloced anything but still valgrind complains.

Any suggestion would be appreciated .


You can run valgrind --leak-check=full ./prog_name to make sure these reachable blocks are not something you can destroy in your program. Many times initializing a library such as libcurl without closing or destroying it will cause leaks. If it's not something you have control over, you can write a suppression file. http://valgrind.org/docs/manual/mc-manual.html section 4.4 has some info and a link to some examples


Sill reachable blocks are probably caused by your standard library not freeing memory used in pools for standard containers (see this faq): which would be a performance optimisation for program exit, since the memory is immediately going to be returned to the operating system anyway.

"Possibly lost" blocks are probably caused by the same thing.

The Valgrind Manual page for memcheck has a good explanation about the different sorts of leaks detected.

0

精彩评论

暂无评论...
验证码 换一张
取 消