cURL / Mailing Lists / curl-library / Single Mail


Re: memory leak when using zlib lib

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

Hello 'moneymachine',

Le 02/10/2012 05:37, moneymachine a écrit :
> void GetNewHtmlSource()
> {
> detect_url= " <>";
> curl_global_init(CURL_GLOBAL_ALL);

> 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.


Maxime Larocque

List admin:
Received on 2012-10-02