cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: memory leak when using zlib lib

From: Michael Wood <esiotrot_at_gmail.com>
Date: Tue, 2 Oct 2012 14:30:43 +0200

On 2 October 2012 11:37, moneymachine <408885336_at_qq.com> wrote:
> im using winxp+vs2008+curl7.27+zlib1.2.7
>
> zlib and curl all complied by /MT into libcurl.lib
>
[...]
> void GetNewHtmlSource()
> {
> CURL * curl;
> CURLcode res;
> struct MemoryStruct chunk;
> chunk.memory=NULL; /* we expect realloc(NULL, size) to work */
> chunk.size = 0; /* no data at this point */
> string detect_url;
> detect_url= "http://www.ip138.com";
> curl_global_init(CURL_GLOBAL_ALL);
> curl = curl_easy_init();
> struct curl_slist *slist = NULL;
> slist = curl_slist_append(slist, NULL);
[...]

What is the purpose of the above line?

If I try that on Linux it segfaults.

> after runing GetNewHtmlSource() in the multithread 100000 time done, about
> 20m memory increased.
> I dont know where the memory leak, pls help.
>
> I try the zlib 1.2.6 1.2.5, all have the leak problems.

I don't see a leak when running it under Linux (after commenting out
the line that tries to append NULL to the header list), but it's with
an older version of libcurl, so not really a valid test.

> BTW, if not complied including zlib and not using CURLOPT_ENCODING, there is
> no memory leak problem.
>
> thank you.

-- 
Michael Wood <esiotrot_at_gmail.com>
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html
Received on 2012-10-02