- 论坛徽章:
- 0
|
最近为了写一段爬虫用到了libcurl,发现总是有12字节的内存泄漏,仔细检查了自己的代码感觉没错,于是怀疑是libcurl的问题。
直接用curl.haxx.se上的simple.c,加上mtrace
- #include <mcheck.h>
- #include <stdio.h>
- #include <stdlib.h>
- #include <curl/curl.h>
- int main(void)
- {
- CURL *curl;
- CURLcode res;
- #ifdef DEBUG
- setenv("MALLOC_TRACE", "./memleak.log", 1);
- mtrace();
- #endif
- curl = curl_easy_init();
- if(curl) {
- curl_easy_setopt(curl, CURLOPT_URL, "http://www.baidu.com");
- res = curl_easy_perform(curl);
- /* always cleanup */
- curl_easy_cleanup(curl);
- }
- return 0;
- }
复制代码 编译后mtrace结果依旧
- Memory not freed:
- -----------------
- Address Size Caller
- 0x08054018 0x12 at 0xb7e806c1
复制代码 再看看log里的0xb7e806c1- @ /lib/tls/i686/cmov/libc.so.6:(inet_ntoa+0xd1)[0xb7e806c1] + 0x8054018 0x12
复制代码
inet_ntoa返回的串没被free?!
请问有人遇到过这样的问题吗?
[ 本帖最后由 pk9284 于 2008-9-14 14:16 编辑 ] |
|