cURL / Mailing Lists / curl-library / Single Mail

curl-library

Memory leak with reusing easy handles?

From: Ates Goral <agoral_at_voicegenie.com>
Date: Thu, 17 Aug 2006 14:51:54 -0400

Here's the description of the problem from a co-worker:

--
We have a process that fetches pages using libcurl.  It creates a multi 
handle to use for fetching, a shared handle used across easy handles for 
a particular session, and easy handles for the individual fetches.  We 
set the CURL_LOCK_DATA_DNS and CURL_LOCK_DATA_COOKIE options on the 
shared handle.  We call curl_multi_add_handle to associate the easy 
handle with the multi handle, curl_multi_perform to perform the fetches, 
and curl_multi_remove_handle once the fetch completes.
 
The test we are having a problem with consists of fetching a single page 
where the fetch takes 10 seconds to complete.  When our process creates 
and cleans up easy handles for each fetch, our memory usage is stable.  
When our process attempts to reuse easy handles from fetch to fetch (and 
possibly across sessions), our process leaks memory. 
 
When we run our process using valgrind (a memory leak detection tool), I 
noticed that it seems to be reporting the leak in Curl_mk_dnscache.  The 
following is a backtrace of one of the reported leaks:
==27473==    at 0x1B903D38: malloc (vg_replace_malloc.c:131)
==27473==    by 0x808754E: Curl_llist_alloc (llist.c:49)
==27473==    by 0x807A524: Curl_hash_init (hash.c:77)
==27473==    by 0x807A594: Curl_hash_alloc (hash.c:98)
==27473==    by 0x807C451: Curl_mk_dnscache (hostip.c:505)
==27473==    by 0x807B239: curl_share_setopt (share.c:74)
 
Does anyone have any insight as to why this would leak or how we could 
fix it?
Received on 2006-08-17