cURL / Mailing Lists / curl-library / Single Mail

curl-library

RE: Possible memory leak in libcurl?

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Wed, 12 Jun 2002 19:41:14 +0200 (MET DST)

On Wed, 12 Jun 2002, Gautam Mani wrote:

> Okay, in my program I create one curl handle and periodically download
> files through it via FTP. This handle is not cleaned up ever until the
> system comes down (which is not expected to happen in a very long time). So
> although I could not find a leak after I brought the system down, the
> memory usage of the system still keeps going up.

For how long? libcurl uses all sorts of caches, and they are expected to keep
on getting "filled up" for quite a few connections.

Oh. You're using 7.9.6, right? There's no pruning of old entries in the DNS
cache there so it can theoreticly continue growing if you continue to use new
host names all the time...

> I have attached a small section of the mallocdebug trace (taken on Win32).
> Please notice that the allocations of 9K which happen in hostip.c:444 are
> not released till the cleanup method is called. I tried to look into the
> code; but since my understanding of the internals is still very basic; I am
> finding it difficult to find a solution.

Those are name lookup buffers. In 7.9.7 we have not only DNS cache pruning,
but also Jacky Lam's neat "shrink-dns-buffers" fixes that makes each single
name resolved information use less space even while in the cache.

> Is this name lookup allocation required everytime... or can it be avoided?

If you use name based URLs libcurl needs to resolve the name.

> Why is the buffer not freed till cleanup is called?

This is a flaw/feature in libcurl 7.9.6 that we fixed in 7.9.7. ;-)

-- 
    Daniel Stenberg -- curl groks URLs -- http://curl.haxx.se/
_______________________________________________________________
Sponsored by:
ThinkGeek at http://www.ThinkGeek.com/
Received on 2002-06-12