Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:37697 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 55319 invoked from network); 18 May 2008 04:02:46 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 18 May 2008 04:02:46 -0000 Authentication-Results: pb1.pair.com header.from=rasmus@lerdorf.com; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=rasmus@lerdorf.com; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain lerdorf.com from 204.11.219.139 cause and error) X-PHP-List-Original-Sender: rasmus@lerdorf.com X-Host-Fingerprint: 204.11.219.139 mail.lerdorf.com Received: from [204.11.219.139] ([204.11.219.139:43841] helo=mail.lerdorf.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 14/D3-16056-56AAF284 for ; Sun, 18 May 2008 00:02:46 -0400 Received: from [192.168.200.148] (c-24-6-219-206.hsd1.ca.comcast.net [24.6.219.206]) (authenticated bits=0) by mail.lerdorf.com (8.14.3/8.14.3/Debian-1) with ESMTP id m4I42eit001335; Sat, 17 May 2008 21:02:41 -0700 Message-ID: <482FAA60.1060209@lerdorf.com> Date: Sat, 17 May 2008 21:02:40 -0700 User-Agent: Thunderbird 2.0.0.4 (Macintosh/20070604) MIME-Version: 1.0 To: Daniel Brown CC: PHP Developers Mailing List References: <482E8391.9080004@lerdorf.com> In-Reply-To: X-Enigmail-Version: 0.95.6 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Greylist: Sender succeeded SMTP AUTH authentication, not delayed by milter-greylist-3.0 (mail.lerdorf.com [204.11.219.139]); Sat, 17 May 2008 21:02:41 -0700 (PDT) Subject: Re: [PHP-DEV] Curl POST emalloc leak? From: rasmus@lerdorf.com (Rasmus Lerdorf) Note that changing it to pass an array of post args instead of passing it a string makes the leak go away. This block of code in interface.c deals with the string case: } else { char *post = NULL; convert_to_string_ex(zvalue); post = estrndup(Z_STRVAL_PP(zvalue), Z_STRLEN_PP(zvalue)); zend_llist_add_element(&ch->to_free.str, &post); error = curl_easy_setopt(ch->cp, CURLOPT_POSTFIELDS, post); error = curl_easy_setopt(ch->cp, CURLOPT_POSTFIELDSIZE, Z_STRLEN_PP(zvalue)); } convert it to a string, estrndup it with the right args and add it to the to_free.str list. Then in the destructor for the resource we have: zend_llist_clean(&ch->to_free.str); So I am obviously missing something. That code looks fine. -Rasmus Daniel Brown wrote: > On Sat, May 17, 2008 at 3:04 AM, Rasmus Lerdorf wrote: >> start 326616 >> GET 327256 >> GET 327276 >> GET 327276 >> GET 327276 >> GET 327276 >> GET 327276 >> GET 327276 >> GET 327276 >> GET 327276 >> GET 327276 >> POST 327516 >> POST 327588 >> POST 327652 >> POST 327712 >> POST 327892 >> POST 328064 >> POST 328228 >> POST 328384 >> POST 328528 >> POST 328628 > > It's not a solution, Rasmus, but here's more data, taken from > 5.2.4. The results were exactly the same, in the same order, after > running your code ten times. > > start 57140 > GET 57820 > GET 57820 > GET 57820 > GET 57820 > GET 57820 > GET 57820 > GET 57820 > GET 57820 > GET 57820 > GET 57820 > POST 58244 > POST 58492 > POST 58728 > POST 58948 > POST 59060 > POST 59164 > POST 59264 > POST 59360 > POST 59452 > POST 59452 > > When changing the for() loop in the curl() function to this: > > for($args='',$i=0;$i<75;$i++) { > $args .= $i == 0 ? "a=$i" : "&a=$i"; > } > ?> > > The results stabilize quicker: > > start 57688 > GET 58340 > GET 58340 > GET 58340 > GET 58340 > GET 58340 > GET 58340 > GET 58340 > GET 58340 > GET 58340 > GET 58340 > POST 58844 > POST 59088 > POST 59416 > POST 59692 > POST 59800 > POST 59904 > POST 59904 > POST 59904 > POST 59904 > POST 59904 >