cURL / Mailing Lists / curl-library / Single Mail

curl-library

RE: Memory leak

From: Nielsen Linus (ext) <Linus.Nielsen_at_elema.siemens.se>
Date: Fri, 12 Oct 2001 10:08:22 +0200

Hi Karim!

It would be easier for us to help you if you could post the source code.

I have a question, though:

When are you freeing the memory that is realloc()ed in MemoryFunction?
If this memory block is reallocated for each request, you will end up
using a lot of memory after a while if you don't free it.

However, we have had a problem with a memory leak in the IPV6 code. This is
believed to be fixed in the latest curl prerelease.
If you are using a machine with IPV6 enabled, you might want to try one
of these options:

1) Reconfigure your libcurl using ./configure --disable-ipv6

2) Download the latest prerelease and try it.

Please report if any of those alternatives solves your problem. We are
indeed interested if there is or was a memory leak in libcurl.

Regards,

Linus Nielsen Feltzing

> -----Original Message-----
> From: Karim Hamed [mailto:karim.hamed_at_WiredMinds.de]
> Sent: den 12 oktober 2001 09:36
> To: curl-library_at_lists.sourceforge.net
> Subject: Memory leak
>
>
> Hi,
>
> I build a shared library that uses the libcurl. The used memroy of my
> application is growing. The application sends a request every ten
> seconds.
>
> I'm using the libcurl as follow:
>
> the first step is to initialize the CURL Pointer the fuchtnion
> curl_easy_init(). Using the struct curl_slist for the header.
>
> the second step is to send the request with curl_easy_perform()
>
> at the end using the two functions above to free all the allocated
> memory.
> curl_slist_free_all()
> curl_easy_cleanup()
>
> In order to be able to receive a response from the web-server, the
> shared library use the following fuction:
> struct MemoryStruct {
> char *memory;
> size_t size;
> }
>
> Memoryfunction(void *ptr, size_t size, size_t nmemb, void *data)
> {
> INT_32 realsize = size * nmemb;
> struct MemoryStruct *mem = (struct MemoryStruct*) data;;
>
> mem->memory = (INT_8 *) realloc (mem->memory, mem->size +
> realsize +
> 1);
> if (mem->memory) {
> memcpy (&(mem->memory[mem->size]), ptr, realsize);
> mem->size += realsize;
> mem->memory[mem->size] = 0;
> }
>
> return realsize;
> }
>
> the application is working without problems only the memory.....
> Regardless this measure the used memory is growing only when
> the libcurl
> functions are used. ;-) Is't possible?
>
> Regards.
> Karim.
>
>
Received on 2001-10-12