curl-library
memory does not freed in windows
Date: Tue, 14 Oct 2008 23:14:28 +0200
Hello all sorry for my bad english
im new to curl and im using it in my application to get info from web
pages , the thing is
im connecting to allot of pages and retrieves information from them .
i notice that every time im
in the line (part of the curl init as you already know ) :
// Attempt to retrieve the remote page
result = curl_easy_perform(m_pcurl);
i getting another ~500k in the mem usage ( i see it in the windows task bar )
that even after im using the command :
curl_easy_cleanup(m_pcurl);
it cleans me something like ~40k so i left with 450k that keeps added
to the memory each time
i do request with curl .
my code ( c++ )
---------------------------------------------------------------------
....
....
m_pcurl = curl_easy_init();
CURLcode result;
// pcurl = curl_easy_init();
if (m_pcurl)
{
// Now set up all of the curl options
curl_easy_setopt(m_pcurl, CURLOPT_ERRORBUFFER, MyClass::m_errorBuffer);
curl_easy_setopt(m_pcurl, CURLOPT_URL,m_szUrl.c_str());
curl_easy_setopt(m_pcurl, CURLOPT_HEADER, 0);
curl_easy_setopt(m_pcurl, CURLOPT_FOLLOWLOCATION, 1);
curl_easy_setopt(m_pcurl, CURLOPT_WRITEFUNCTION,MyClass::writer);
curl_easy_setopt(m_pcurl, CURLOPT_WRITEDATA,this);
// Attempt to retrieve the remote page
result = curl_easy_perform(m_pcurl);
// Always cleanup
curl_easy_cleanup(m_pcurl);
}
...
...
void MyClass::writer(void *buffer, size_t size, size_t nmemb,void* f)
{
// Call non-static member function.
static_cast<Http*>(f)->setBuffer((char*)buffer,size,nmemb);
}
int MyClass::setBuffer(char *buffer, size_t size, size_t nmemb)
{
// What we will return
int result = 0;
// Is there anything in the buffer?
if (buffer!=NULL)
{
// Append the data to the buffer
m_szbuffer.append(buffer, size * nmemb);
// How much did we write?
result = size * nmemb;
}
buffer = NULL ;
return result;
}
Received on 2008-10-14