cURL / Mailing Lists / curl-library / Single Mail

curl-library

RE: Possible memory leak in libcurl?

From: Gautam Mani <Gautam.Mani_at_Mobileum.com>
Date: Wed, 12 Jun 2002 15:15:49 -0700

Hi,
I have upgraded to 4.9.7 and it looks better ... although there is still a
small leak - it is still at the same place; and memanalyse of a small
section gives me:

At 4588c4, there's 128 bytes.
 allocated by /install/curl-7.9.6/lib/hostip.c:499
At 458984, there's 128 bytes.
 allocated by /install/curl-7.9.6/lib/hostip.c:499
At 458ac4, there's 128 bytes.
 allocated by /install/curl-7.9.6/lib/hostip.c:499
At 458704, there's 256 bytes.
 allocated by /install/curl-7.9.6/lib/url.c:1437

The 256 bytes allocated are freed in the next iteration, so that is not a
problem. The main issue is the 128 bytes allocated at hostip:499.
Any pointers?

Cheers,
Gautam

-----Original Message-----
From: Gautam Mani
To: ''libcurl Mailing list ' '
Sent: 6/12/2002 11:55 AM
Subject: RE: Possible memory leak in libcurl?

Hi,

Thanks for the reply. There is only one host that I connect to, only the
URL changes everytime which is why I am unable to understand why the
cache keeps growing. Also since I use the same handle all along, there
is no new connection made to the server.
I have run these tests for a fairly long period - in fact I have
monitored the sample program I sent earlier to make 1000 FTP listings on
one handle... and the heap size keeps growing. A small section of the
analyzed memory dump looks like:

<snip>...

Is there is a hashing bug in this version, or would upgrading to 4.9.7
make no difference?

TIA,
Gautam

-----Original Message-----
From: Daniel Stenberg
To: Gautam Mani
Cc: 'libcurl Mailing list '
Sent: 6/12/2002 10:41 AM
Subject: RE: Possible memory leak in libcurl?

On Wed, 12 Jun 2002, Gautam Mani wrote:

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. ;-)

_______________________________________________________________

Sponsored by:
ThinkGeek at http://www.ThinkGeek.com/
Received on 2002-06-13