cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Memory leak in libcurl

From: Huzaifa Al Nahas <halnahas_at_gmail.com>
Date: Mon, 22 Dec 2008 10:59:56 -0800

Hi Dan,
The memory leak is reported even if curl_global_cleanup() is called.
This is true whether I call curl_global_init directly or indirectly.
The code below reports a memory leak

#include <iostream>
#include <curl/curl.h>
#include <crtdbg.h>

#define _CRTDBG_MAP_ALLOC

int main(int argc, char *argv[])
{
  CURL *curl;

  curl_global_init(CURL_GLOBAL_ALL|CURL_GLOBAL_WIN32);

  curl = curl_easy_init();

  curl_easy_cleanup(curl);

  curl_global_cleanup();

  if (_CrtDumpMemoryLeaks())
          std::cout << "Memory Leak" << std::endl;
  else
          std::cout << "No memory leak found" << std::endl;

  return 0;
}

- Huzaifa

On Fri, Dec 19, 2008 at 10:34 PM, Dan Fandrich <dan_at_coneharvesters.com> wrote:
> On Fri, Dec 19, 2008 at 07:45:13PM -0800, Huzaifa Al Nahas wrote:
>> Greetings,
>> VC++ 8.0 is reporting a memory leak after curl cleans an easy handle.
>> Is this a known issue?
>
> curl_easy_init() implicitly calls curl_global_init() if you don't call the
> latter explicitly. You need to call curl_global_cleanup() explicitly to
> free memory allocated by it.
>
>>>> Dan
> --
> http://www.MoveAnnouncer.com The web change of address service
> Let webmasters know that your web site has moved
>
Received on 2008-12-22