cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: [PATCH] Re: libcurl memleak

From: Avery Fay <avery_fay_at_symantec.com>
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
                      <daniel_at_haxx.se> To: libcurl Mailing list <curl-library_at_lists.sourceforge.net>
                      Sent by: cc:
                      curl-library-admin_at_lists.sour Subject: [PATCH] Re: libcurl memleak
                      ceforge.net
                                                                                                                                                
                                                                                                                                                
                      10/30/2002 01:58 AM
                      Please respond to
                      curl-library
                                                                                                                                                
                                                                                                                                                

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
ran
> 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
wouldn't
> help much (I give URL's like http://10.0.0.1/, etc.).

I agree that it makes sense. However, after checking out things, there is
no
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 @@
   }
 #endif

+#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);
   }
+#endif

   time(&now);

--
 Daniel Stenberg -- curl, cURL, Curl, CURL. Groks URLs.
-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
-------------------------------------------------------
This sf.net email is sponsored by: Influence the future 
of Java(TM) technology. Join the Java Community 
Process(SM) (JCP(SM)) program now. 
http://ads.sourceforge.net/cgi-bin/redirect.pl?sunm0004en
Received on 2002-10-30