I use libcurl multipart upload file, and I get leak info in the XCode instruments.
curl_formadd seem to have leak.
The leak info is below:
Bytes Used # Leaks Symbol Name
656 Bytes 100.0% 17 thread_start
656 Bytes 100.0% 17 _pthread_start
656 Bytes 100.0% 17 _ZN7cocos2d9extensionL13networkThreadEPv
656 Bytes 100.0% 17 cocos2d::extension::processPostMultipartTask(cocos2d::extension::CCHttpRequest, unsigned long ()(void, unsigned long, unsigned long, void), void, int)
656 Bytes 100.0% 17 curl_formadd
384 Bytes 58.5% 6 calloc
144 Bytes 21.9% 3 strdup
144 Bytes 21.9% 3 malloc
128 Bytes 19.5% 8 memdup
My code is below:
CURLcode code = CURL_LAST;
CURL *curl = curl_easy_init();
do {
if (!configureCURL(curl)) {
break;
}
/* handle custom header data */
/* create curl linked list */
struct curl_slist *cHeaders=NULL;
/* get custom header data (if set) */
std::vector<std::string> headers=request->getHeaders();
if(!headers.empty())
{
for(std::vector<std::string>::iterator it=headers.begin();it!=headers.end();it++)
{
/* append custom headers one by one */
cHeaders=curl_slist_append(cHeaders,it->c_str());
}
/* set custom headers for curl */
code = curl_easy_setopt(curl, CURLOPT_HTTPHEADER, cHeaders);
if (code != CURLE_OK) {
break;
}
}
/*
<form enctype="multipart/form-data" method="POST" action="http://xxx.xxx.xxx.xxx/xxxxx/public/member/upload" accept-charset="UTF-8">
<input type="file" name="uploadfile">
<input type="text" name="u_id" value="" id="u_id">
<input type="text" name="cali" value="" id="cali">
<input type="submit" value="Upload">
</form>
*/
struct curl_httppost *formpost = 0;
struct curl_httppost *lastptr = 0;
map<string,string>::iterator it = formData.begin();
for(;it != formData.end(); it++)
{
curl_formadd(&formpost,
&lastptr,
CURLFORM_COPYNAME, (*it).first.c_str(),
CURLFORM_COPYCONTENTS, (*it).second.c_str(),
CURLFORM_END);
}
curl_formadd(&formpost, &lastptr, CURLFORM_PTRNAME, "uploadfile", CURLFORM_FILE, postMultipartFilePath, CURLFORM_END);
code = curl_easy_setopt(curl, CURLOPT_URL, request->getUrl());
if (code != CURLE_OK) {
break;
}
curl_easy_setopt(curl, CURLOPT_HTTPPOST, formpost);
if (code != CURLE_OK) {
break;
}
code = curl_easy_perform(curl);
if (code != CURLE_OK) {
break;
}
curl_formfree(formpost);
//curl_formfree(lastptr);//need use that remove leak? it will crash
/* free the linked list for header data */
curl_slist_free_all(cHeaders);
code = curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, responseCode);
if (code != CURLE_OK || *responseCode != 200) {
code = CURLE_HTTP_RETURNED_ERROR;
}
} while (0);
if (curl) {
curl_easy_cleanup(curl);
}
So what do I miss something to do?
Thanks.
Regards.
We have at least 21 test cases involving formposting and none of them show any leak. You need to A) provide us with a full example that leaks memory and B) tell us exactly which libcurl version it is - and if it isn't a recent version I'd like to ask you to make a test with the latest version as well to see how that behaves.
I use libcurl version 7.26.0,the timestamp is Thu May 24 16:05:42 UTC 2012.
I already change the apple latest ios version 7.30,
and I can't find the leak in the profile result.
So I think the leak issue already fixed.
I use libcurl version 7.26.0,the timestamp is Thu May 24 16:05:42 UTC 2012.
I already change the apple latest ios version 7.30,and I can't find the leak in the profile result.
So I think the leak issue already fixed.
寄件者: Daniel Stenberg bagder@users.sf.net
收件者: [curl:bugs] 1241@bugs.curl.p.re.sf.net
寄件日期: 2013/6/7 (週五) 4:08 AM
主旨: [curl:bugs] #1241 curl_formadd leak
We have at least 21 test cases involving formposting and none of them show any leak. You need to A) provide us with a full example that leaks memory and B) tell us exactly which libcurl version it is - and if it isn't a recent version I'd like to ask you to make a test with the latest version as well to see how that behaves.
[bugs:#1241] curl_formadd leak
<form enctype="multipart/form-data" method="POST" action="http://xxx.xxx.xxx.xxx/xxxxx/public/member/upload" accept-charset="UTF-8"> <input type="file" name="uploadfile"> <input type="text" name="u_id" value="" id="user-content-u_id"> <input type="text" name="cali" value="" id="user-content-cali"> <input type="submit" value="Upload"> </form>/ struct curl_httppostStatus: open
Created: Thu Jun 06, 2013 09:54 AM UTC by yayaigo
Last Updated: Thu Jun 06, 2013 09:54 AM UTC
Owner: Daniel Stenberg
I use libcurl multipart upload file, and I get leak info in the XCode instruments.
curl_formadd seem to have leak.
The leak info is below:
Bytes Used # Leaks Symbol Name
656 Bytes 100.0% 17 thread_start
656 Bytes 100.0% 17 _pthread_start
656 Bytes 100.0% 17 _ZN7cocos2d9extensionL13networkThreadEPv
656 Bytes 100.0% 17 cocos2d::extension::processPostMultipartTask(cocos2d::extension::CCHttpRequest, unsigned long ()(void, unsigned long, unsigned long, void), void, int)
656 Bytes 100.0% 17 curl_formadd
384 Bytes 58.5% 6 calloc
144 Bytes 21.9% 3 strdup
144 Bytes 21.9% 3 malloc
128 Bytes 19.5% 8 memdup
My code is below:
CURLcode code = CURL_LAST; CURL curl = curl_easy_init(); do { if (!configureCURL(curl)) { break; } / handle custom header data / / create curl linked list / struct curl_slist cHeaders=NULL; / get custom header data (if set) / std::vector<std::string> headers=request->getHeaders(); if(!headers.empty()) { for(std::vector<std::string>::iterator it=headers.begin();it!=headers.end();it++) { / append custom headers one by one / cHeaders=curl_slist_append(cHeaders,it->c_str()); } / set custom headers for curl / code = curl_easy_setopt(curl, CURLOPT_HTTPHEADER, cHeaders); if (code != CURLE_OK) { break; } } / </std::string></std::string>
formpost = 0; struct curl_httppost lastptr = 0; map<string,string>::iterator it = formData.begin(); for(;it != formData.end(); it++) { curl_formadd(&formpost, &lastptr, CURLFORM_COPYNAME, (it).first.c_str(), CURLFORM_COPYCONTENTS, (it).second.c_str(), CURLFORM_END); } curl_formadd(&formpost, &lastptr, CURLFORM_PTRNAME, "uploadfile", CURLFORM_FILE, postMultipartFilePath, CURLFORM_END); code = curl_easy_setopt(curl, CURLOPT_URL, request->getUrl()); if (code != CURLE_OK) { break; } curl_easy_setopt(curl, CURLOPT_HTTPPOST, formpost); if (code != CURLE_OK) { break; } code = curl_easy_perform(curl); if (code != CURLE_OK) { break; } curl_formfree(formpost); //curl_formfree(lastptr);//need use that remove leak? it will crash / free the linked list for header data / curl_slist_free_all(cHeaders); code = curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, responseCode); if (code != CURLE_OK || *responseCode != 200) { code = CURLE_HTTP_RETURNED_ERROR; } } while
(0); if (curl) { curl_easy_cleanup(curl); }
So what do I miss something to do?
Thanks.
Regards.
Sent from sourceforge.net because you indicated interest in https://sourceforge.net/p/curl/bugs/1241/
</string,string>To unsubscribe from further messages, please visit https://sourceforge.net/auth/subscriptions/
Related
Bugs:
#1241Then if this is no longer a problem in the latest version I consider this bug fixed and this issue is closed!
LinkedIn
I'd like to add you to my professional network on LinkedIn.
敬錞潘
Programmer at CITM
Taiwan
Confirm that you know 敬錞潘:
https://www.linkedin.com/e/-ozowl2-hs7n59kx-6w/isd/20471250134/so9QJtOd/?hs=false&tok=0Zc01zlkJpqm81
--
You are receiving Invitation to Connect emails. Click to unsubscribe:
http://www.linkedin.com/e/-ozowl2-hs7n59kx-6w/V3EL_D-as5IPgZkV7e-OgbkaNPISiSqrtUijIuda/goo/1241%40bugs%2Ecurl%2Ep%2Ere%2Esf%2Enet/20061/I6586441529_1/?hs=false&tok=2On8A-OHVpqm81
(c) 2012 LinkedIn Corporation. 2029 Stierlin Ct, Mountain View, CA 94043, USA.
请点这里申请邮箱升级?