cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: libcurl memleak

From: Avery Fay <avery_fay_at_symantec.com>
Date: Tue, 29 Oct 2002 13:24:30 -0500

Yes, I do:

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. At one point, I tried setting CURLOPT_DNS_USE_GLOBAL_CACHE
to 0, but I ran into other problems doing that. 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.).

Here's a sample program:

#include <curl/curl.h>

void curl_memdebug(const char *logname);
static size_t update_read(void *ptr, size_t size, size_t nmemb, void
*stream);

int main()
{
      int i;
      CURL *curl;

      curl_memdebug("mem_debug.txt");

      curl = curl_easy_init();
      curl_easy_setopt(curl, CURLOPT_URL, "http://10.242.110.80/1K.bin");
      curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, update_read);
      curl_easy_setopt(curl, CURLOPT_DNS_CACHE_TIMEOUT, 0);

      for (i = 0; i < 5000; ++i)
      {
            curl_easy_setopt(curl, CURLOPT_FORBID_REUSE, TRUE);
            curl_easy_perform(curl);
      }

      curl_easy_cleanup(curl);

      return 0;
}

static size_t update_read(void *ptr, size_t size, size_t nmemb, void
*stream)
{
      return size * nmemb;
}

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: Re: libcurl memleak
                      ceforge.net
                                                                                                                                                
                                                                                                                                                
                      10/28/2002 04:59 PM
                      Please respond to
                      curl-library
                                                                                                                                                
                                                                                                                                                

On Mon, 28 Oct 2002, Avery Fay wrote:

> I reran my program single threaded and the analysis looks much more sane
> although it's still huge. Here's a snippet from the beginning (all looks
> that same):
>
> Leak detected: memory still allocated: 845600 bytes
> At 80f0074, there's 160 bytes.
> allocated by hostip.c:534
> At 806d514, there's 160 bytes.
> allocated by hostip.c:534
> At 8115cc4, there's 160 bytes.
> allocated by hostip.c:534

Hm. This certainly indicates that we might have a problem with the memory
allocated on line 534 in hostip.c.

Have you set any particular options regarding the DNS cache? Or even, can
you
make a tiny program that repeats this problem and show us the code?

--
 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:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
Received on 2002-10-29