cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: memory leak? help needed

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Thu, 12 Oct 2006 14:02:49 +0200 (CEST)

On Thu, 12 Oct 2006, Tom Jerry wrote:

> memanalyze.pl my_curl_debug.log
>
> I saw nothing happens. I guess it mean there are no leaks.

Correct.

> So after analyzing the debug files, I believe that the memory is freed when
> my application goes down (I also see it in my own prints), and there aren't
> any leaks eventually.

This log is what libcurl creates so these are all allocs and frees done by
libcurl. So if libcurl frees the memory when you close it down, it is by
definition not a leak.

> But during my service operation, the memory is always growing.
> Two places, for example, that I saw (using a debugger) an allocation that is
> not freed when sending a POST request are:
> 1) conn = (struct connectdata *)calloc(sizeof(struct connectdata), 1); -
> url.c 2614
> 2) conn->pathbuffer=(char *)malloc(urllen+2); - url.c 2674

If they would never be freed then you'd have a leak and then the memanalyze
script would've said so.

> This memory is probably deallocated when my service goes down, but is is not
> deallocated after the POST request ends.

Let's not draw quick conclusions. Yes the memory is kept after you've made
your request, since you can make another one afterwards and it would re-use
that connection and allocated data.

As you will see if you continue to make requests and re-using the same handle
(or even if you don't re-use it), the amount of used memory will go up
initially when libcurl populates it various caches and buffers but it won't
continue indefinitely and far as I know there is no memory leak in recent
libcurls.

I think you're blowing a whistle here - way too early.

> Since my application is a service (which should never go down), I have a
> serious problem.

I don't see why you do. This is not a leak, it is a controlled memory
allocation.

> Do you have any idea for a solution?

AFAICS, there's no problem that needs a fix.

-- 
  Commercial curl and libcurl Technical Support: http://haxx.se/curl.html
Received on 2006-10-12