cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Memory leak

From: Sterling Hughes <sterling_at_designmultimedia.com>
Date: Fri, 12 Oct 2001 09:50:43 +0200 (CEST)

On Fri, 12 Oct 2001, Karim Hamed wrote:

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

    are you free'ing this data?

    -Sterling

> 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