cURL / Mailing Lists / curl-library / Single Mail

curl-library

strange mem behavior

From: Devel <devel_at_integra-sc.it>
Date: Wed, 24 May 2006 18:02:44 +0200

Hi all,
i have this function in my app SDL based. For test i call this function in a loop while. Using top cmd (i'm using linux) i see that VIRT mem associated with my apps grow every time i call curl_easy_perform and it doesn't relased with curl_easy_perform.
Can you help me to debug this?
Thanks!

int netcam_get (int index)
{
        CURL *curl=NULL;
        CURLcode ret;
        
        FILE *jpegfile;
        char *filename="/tmp/tmp.jpg";
        char userpass[40];
        char url[300];
        char ctrl_str[300];
// char error_buf[CURL_ERROR_SIZE];

        if ((jpegfile=fopen(filename,"w"))==NULL)
                return -1;
        curl=curl_easy_init();
        if (curl) {
                if(verbose>2)
                        curl_easy_setopt(curl,CURLOPT_VERBOSE, 1);
                /*
                curl_easy_setopt(curl,CURLOPT_CONNECTTIMEOUT, 10);
                curl_easy_setopt(curl,CURLOPT_TIMEOUT, 30);
                curl_easy_setopt(curl,CURLOPT_NOSIGNAL, 1);
                */
                curl_easy_setopt(curl, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
                curl_easy_setopt(curl, CURLOPT_FILE, jpegfile);
                curl_easy_setopt(curl, CURLOPT_URL, url);
                if (strcmp(userpass,":"))
                        curl_easy_setopt(curl, CURLOPT_USERPWD, userpass);
                else
                        if(verbose>1)
                                log2f("Nessuna password assegnata",NULL,NULL,NULL,verbose);

                ret=curl_easy_perform(curl);
                if (ret!=0) {
                        switch(ret){
                                case CURLE_COULDNT_CONNECT:
                                        log2f("next_cam()- Non posso connettermi all'url:",url,curl_easy_strerror(ret),NULL,verbose);
                                        break;
                                default:
                                        log2f("Error getting netcam image:",curl_easy_strerror(ret),NULL,NULL,verbose);
                        }
                        curl_easy_cleanup(curl);
                        fclose(jpegfile);
                                return -1;
                }
        }
        curl_easy_cleanup(curl);
        fclose(jpegfile);
        return 0;
}
Received on 2006-05-24