的valgrind检测内存泄漏使用时的libcurl(无SSL) [英] valgrind detects memory leaks when using libcurl (no ssl)

查看:462
本文介绍了的valgrind检测内存泄漏使用时的libcurl(无SSL)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的C程序中我使用的libcurl的一些基本功能。今天我跑的valgrind以检查我是否有内存泄漏和Valgrind的疯报告多个错误。

我跟踪它基本上下降到:

 卷曲*袅袅;
卷曲code资源;卷曲= curl_easy_init();
// ...
curl_easy_cleanup(卷曲);

如果我删除全部采用的libcurl,Valgrind的犯规报告任何错误的code。

我已经读过,有使用具有的libcurl和SSL Valgrind的一些问题,但我不获取任何HTTPS URL中等等。

我能做些什么?可我做的valgrind闭嘴libcurl的错误(可能误报?),并从我的code仅报告错误?由于错误尽管libcurl的Valgrind的输出还是比较混乱的最简单的使用量巨大。

不幸的是我没有内置安装的libcurl的调试,这样的valgrind甚而不报告的行号/文件,它deteced泄漏。错误消息如下:

  == == 27330
== == 27330 HEAP摘要:
== == 27330在退出,使用:34,960 2,406中的字节块
== == 27330总堆的使用情况:20,130 allocs,17724的FreeS,2511576字节分配
== == 27330
== == 27330 40(20直接,间接20)字节1块负的战绩445的383肯定是丢失
== == 27330在0x4025BD3:的malloc(vg_replace_malloc.c:236)
== == 27330通过0x4B173FD:???
== == 27330通过0x4B17A8B:???
== == 27330通过0x4B84957:???
== == 27330通过0x4B849FD:???
== == 27330通过0x4B72814:???
== == 27330通过0x4B734C1:???
== == 27330通过0x4B78DE2:???
== == 27330通过0x4B7524B:???
== == 27330通过0x49B2F76:???
== == 27330通过0x49C9ECB:???
== == 27330通过0x49BC96A:???
...


解决方案

我知道这个答案是一年后到来,但有人可能会觉得这仍然是有帮助的。结果
调用 curl_easy_cleanup(卷曲)后,尝试添加到通话curl_global_cleanup()

这是为我工作。

In my C program I use some basic functions of libcurl. Today I ran valgrind in order to check if I have memory leaks and valgrind went crazy reporting multiple errors.

I tracked it basically down to:

CURL *curl;
CURLcode res;

curl = curl_easy_init();
// ...
curl_easy_cleanup(curl);

If I remove the code that uses libcurl completely, valgrind doesnt report any errors.

I already read that there are some problems using valgrind with libcurl and ssl, but I dont fetch any https urls or the like.

What can I do? Can I make valgrind shut up about libcurl errors (possible false positives?) and report only errors from my code? Due to the huge amount of errors despite most simple usage of libcurl the output of valgrind is quite confusing.

Unfortunately I dont have a debug built of libcurl installed, so valgrind doesnt even report the line numbers/files where it deteced the leaks. The error messages look like:

==27330== 
==27330== HEAP SUMMARY:
==27330==     in use at exit: 34,960 bytes in 2,406 blocks
==27330==   total heap usage: 20,130 allocs, 17,724 frees, 2,511,576 bytes allocated
==27330== 
==27330== 40 (20 direct, 20 indirect) bytes in 1 blocks are definitely lost in loss record 383 of 445
==27330==    at 0x4025BD3: malloc (vg_replace_malloc.c:236)
==27330==    by 0x4B173FD: ???
==27330==    by 0x4B17A8B: ???
==27330==    by 0x4B84957: ???
==27330==    by 0x4B849FD: ???
==27330==    by 0x4B72814: ???
==27330==    by 0x4B734C1: ???
==27330==    by 0x4B78DE2: ???
==27330==    by 0x4B7524B: ???
==27330==    by 0x49B2F76: ???
==27330==    by 0x49C9ECB: ???
==27330==    by 0x49BC96A: ???
...

解决方案

I know this answer is coming a year later, but someone may still find it helpful.
After the call to curl_easy_cleanup(curl), try adding a call to curl_global_cleanup().

That worked for me.

这篇关于的valgrind检测内存泄漏使用时的libcurl(无SSL)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆