cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: memory leak when using zlib lib

From: Maxime Larocque <maxmtl2002_at_yahoo.ca>
Date: Tue, 02 Oct 2012 08:24:05 -0400

Hello 'moneymachine',

Le 02/10/2012 05:37, moneymachine a écrit :
> void GetNewHtmlSource()
> {
>
[...snip...]
> detect_url= "http://www.ip138.com <http://www.ip138.com/>";
> curl_global_init(CURL_GLOBAL_ALL);
[...snip...]

> curl_global_cleanup();
> }
> after runing GetNewHtmlSource() in the multithread 100000 time done,
> about 20m memory increased.
> I dont know where the memory leak, pls help.

How do you run GetNewHtmlSource()? Sequentially in a single thread or
from multiple threads?

If run from multiple threads, you may get in trouble, since
curl_global_init()/curl_global_cleanup() must be called only once for
the application (or at least from a single thread). It's described in
the man page. We once got into trouble in a multithreaded application
because of that (in our case, NULL pointer access in OpenSSL...). It was
not an http access in our case, so your result may be different.

Regards,

Maxime Larocque

-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2012-10-02