cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Memory Leak?

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Wed, 9 Oct 2002 14:11:19 +0200 (MET DST)

On Tue, 8 Oct 2002, Brian Feaver wrote:

(Cross-posted to the libcurl list, please take follow-ups there, this is a
libcurl issue.)

> I'm currently using version 7.10. I'm using cURL to download images from a
> webserver continuously and then save them to disk. Everytime I want a new
> image, I call curl_easy_perform (from inside an infinate loop). Here's a
> snipit of my code:
>
> curl_easy_setopt(curl,CURLOPT_URL,url);
> curl_easy_setopt(curl,CURLOPT_USERPWD,userAndPassword);
> curl_easy_setopt(curl,CURLOPT_NOPROGRESS,1);
> curl_easy_setopt(curl,CURLOPT_VERBOSE,0);
>
> while(true)
> {
> // Open file for writing
> jpgFile = fopen(jpgPath,"w");
>
> curl_easy_setopt(curl,CURLOPT_WRITEDATA,jpgFile);
> res = curl_easy_perform(curl);
> fclose(jpgFile);
> jpgFile = NULL;
> }
>
> I have also tried putting all my cURL calls into its own function
> (including a call to curl_easy_cleanup) and then just looping the funciton
> call. Both of these ways cause the process to increase it's memory size.
> This is the only part that repeats and therefor it can't be leaking
> anywhere else.
>
> Any suggestions or hints would be appreciated.

I really need to write down a proper How To Track Down libcurl Memory Leaks
document, but until I have, read this:

        http://curl.haxx.se/mail/lib-2002-06/0080.html

If you just make sure your program have an exit point, you can for example
let it download the document N number of times and then cleanup and exit,
then the above instructions are perfect to detect exactly where in libcurl
the allocation is made that was never freed.

And if none is found in libcurl, the leak is in your code!

-- 
 Daniel Stenberg -- curl related mails on curl related mailing lists please
-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
Received on 2002-10-09