cURL / Mailing Lists / curl-library / Single Mail

curl-library

cURL HTTPS implementation appears to be leaking memory

From: Andre Guibert de Bruet <andy_at_siliconlandmark.com>
Date: Wed, 30 May 2007 18:24:53 -0400

Hi,

I have been trying to track down the source of the increasing VSZ and
RSS in a program which uses libcurl for a couple of weeks and came up
with a simple test case which displays the same thing as my program.
The source for the test case, "curlprofiler.cpp", is at the bottom of
this email and compiles on not-so-recent RedHat Linux with:

g++ -static curlprofiler.cpp -L/lib -L/usr/lib -L/usr/kerberos/lib -
lcurl -lssl -lc -lstdc++ -lm -lgcc -lcrypto -ldl -lz -lresolv -lkrb5 -
lk5crypto -lcom_err

The output of "ps auxw |grep curlprofiler |grep -v grep" called
repeatedly will show a growth in the VSZ and RSS which, from my
testing is not directly correlated with the number of HTTPS POST
operations being performed. On this i686 RedHat 9 machine, the amount
leaked is 4KB on a yet undetermined interval. This amount adds up to
quite a few megabytes over time for applications which are to run 24/7.

Am I missing something blatantly obvious? Any and all pointers/
comments/suggestions are greatly appreciated.

Cheers,

/* Andre Guibert de Bruet * 6f43 6564 7020 656f 2e74 4220 7469 6a20 */
/* Code poet / Sysadmin * 636f 656b 2e79 5320 7379 6461 696d 2e6e */
/* GSM: +1 734 846 8758 * 5520 494e 2058 6c73 7565 6874 002e 0000 */
/* WWW: siliconlandmark.com * C/C++, Java, Perl, PHP, SQL, XHTML, XML */

#include <stdio.h>
#include <unistd.h>
#include <curl/curl.h>

int main (int argc, char **argv)
{
         const char postfieldscontent[] = "<?xml version=\"1.0\" ?>
\n<Data />";
         const char currentURL[] = "https://66.184.117.20/curl/";
         int ret = 0;

         for (int i = 0; i < 5000; i++)
         {
                 FILE *infile = fopen ( "output", "w+" );
                 void *www = (void *) curl_easy_init ();
                 curl_easy_setopt ( (CURL*)www, CURLOPT_FILE, infile );
                 curl_easy_setopt ( (CURL*)www, CURLOPT_URL,
currentURL );
                 curl_easy_setopt ( (CURL*)www,
CURLOPT_SSL_VERIFYHOST, 0);
                 curl_easy_setopt ( (CURL*)www,
CURLOPT_SSL_VERIFYPEER, 0);
                 curl_easy_setopt ( (CURL*)www, CURLOPT_POST );
                 curl_easy_setopt ( (CURL*)www, CURLOPT_POSTFIELDS,
postfieldscontent );

                 if ( (ret = curl_easy_perform ( (CURL*)www )) == 0 )
                         printf ( "%d successful. address to www %p
\n", i, www );
                 else
                         printf ( "%d failed. ERROR(%d). address to
www %p\n", i, ret, www );

                 curl_easy_cleanup ( (CURL *) www );
                 fclose ( infile );
         }
         return 0;
}
Received on 2007-05-31