cURL / Mailing Lists / curl-library / Single Mail


Re: [PATCH] Re: libcurl memleak

From: Avery Fay <>
Date: Wed, 30 Oct 2002 15:25:30 -0500

This solves the leak in my program. I'm going to go back and try without
setting CURLOPT_DNS_CACHE_TIMEOUT to 0 to see if I can reproduce the
crashes. Also, what is the default for CURLOPT_DNS_USE_GLOBAL_CACHE? I was
under the assumption that setting this to 0 would make a separate cache for
each curl_easy instance. So, I should be safe setting it to 0 in a
multithreaded environment.

Avery Fay

                      Daniel Stenberg
                      <> To: libcurl Mailing list <>
                      Sent by: cc:
                      curl-library-admin_at_lists.sour Subject: [PATCH] Re: libcurl memleak
                      10/30/2002 01:58 AM
                      Please respond to

On Tue, 29 Oct 2002, Avery Fay wrote:

> curl_easy_setopt(curl, CURLOPT_DNS_CACHE_TIMEOUT, 0);
> I did this originally because I was having sporadic crashes in libcurl's
> DNS cache code.

Hm. We need to get that looked into if that is the case still.

> At one point, I tried setting CURLOPT_DNS_USE_GLOBAL_CACHE to 0, but I
> into other problems doing that.

Yes, you can't use that multi-threaded.

> Anyway, my program never resolves names so I figured using a cache
> help much (I give URL's like, etc.).

I agree that it makes sense. However, after checking out things, there is
good way to free the data unless it is stored in the cache, as the code is
written now. Thus, I ran your test program without any memory leak after
having done minor patch shown below. I'm of course interested in knowing if
this fixes your problem.

diff -u -r1.75 hostip.c
--- lib/hostip.c 21 Oct 2002 13:20:30 -0000 1.75
+++ lib/hostip.c 30 Oct 2002 06:55:29 -0000
@@ -218,11 +218,13 @@

+#if 0
   /* If the host cache timeout is 0, we don't do DNS cach'ing
      so fall through */
   if (data->set.dns_cache_timeout == 0) {
     return Curl_getaddrinfo(data, hostname, port, &bufp);


 Daniel Stenberg -- curl, cURL, Curl, CURL. Groks URLs.
This email is sponsored by:ThinkGeek
Welcome to geek heaven.
This email is sponsored by: Influence the future 
of Java(TM) technology. Join the Java Community 
Process(SM) (JCP(SM)) program now.
Received on 2002-10-30