在我的 C 程序中,我使用 libcurl 的一些基本函数。今天我运行 valgrind 来检查是否存在内存泄漏,并且 valgrind 疯狂地报告了多个错误。
我基本上追踪到:
CURL *curl;
CURLcode res;
curl = curl_easy_init();
// ...
curl_easy_cleanup(curl);
如果我完全删除使用 libcurl 的代码,valgrind 不会报告任何错误。
我已经读到,将 valgrind 与 libcurl 和 ssl 一起使用存在一些问题,但我没有获取任何 https url 等。
我能做些什么?我可以让 valgrind 关闭 libcurl 错误(可能是误报?)并仅报告我的代码中的错误吗?尽管 libcurl 的使用最为简单,但由于存在大量错误,因此 valgrind 的输出相当混乱。
不幸的是,我没有安装 libcurl 的调试版本,因此 valgrind 甚至不报告检测到泄漏的行号/文件。错误消息如下所示:
==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: ???
...