ID: 39037 User updated by: eugen at id dot com dot ua Reported By: eugen at id dot com dot ua -Status: Bogus +Status: Open Bug Type: cURL related Operating System: Fedora Core 5 PHP Version: 5.1.6 New Comment:
I think curl_close() MUST release memory. And it does when using curl_exec() like this: <?php $ch = curl_init(); // set URL and other appropriate options curl_setopt($ch, CURLOPT_URL, "http://www.php.net/"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // grab URL and pass it to the browser curl_exec($ch); $memory_usage = memory_get_usage(); // close curl resource, and free up system resources curl_close($ch); echo "Memory usage was: $memory_usage, after curl_close - ".(memory_get_usage() - $memory_usage)." bytes more\n"; ?> In this code curl_close() releases used memory. But when I use it with curl_multi it doesn't. Why? If it is caching then it must be a bad caching, i guess... Previous Comments: ------------------------------------------------------------------------ [2006-10-04 17:22:14] [EMAIL PROTECTED] All memory leaks are reported on shutdown. What you see is just the way zend memory manager works trying to reduce malloc/realloc/free calls and caching some memory. No bug here. ------------------------------------------------------------------------ [2006-10-04 16:01:03] eugen at id dot com dot ua Here is short script without external resources requipment: <?php echo "Initial memory usage: ".memory_get_usage()."\n"; $tasks = array( "http://www.google.com", "http://www.php.net" ); $curl_handles = array(); $mh = curl_multi_init(); reset($tasks); while (list($index, $row)=each($tasks)) { $cid = curl_init($row); curl_setopt($cid, CURLOPT_RETURNTRANSFER, 1); curl_multi_add_handle($mh, $cid); $curl_handles[ $index ] = $cid; } do { $n = curl_multi_exec($mh, $active); $info = curl_multi_info_read($mh); if (!empty($info)) { reset($curl_handles); while (list($task_id, $handle)=each($curl_handles)) { if ($handle == $info['handle']) { $done_task_id = $task_id; break; } } echo "Task $tasks[$done_task_id] completed\n"; $memory_usage = memory_get_usage(); // this should free up resources curl_close($info['handle']); $diff = memory_get_usage() - $memory_usage; echo "Memory usage was: $memory_usage, after curl_close: $diff bytes more\n"; } } while ($active); ?> ------------------------------------------------------------------------ [2006-10-04 15:35:51] [EMAIL PROTECTED] Thank you for this bug report. To properly diagnose the problem, we need a short but complete example script to be able to reproduce this bug ourselves. A proper reproducing script starts with <?php and ends with ?>, is max. 10-20 lines long and does not require any external resources such as databases, etc. If the script requires a database to demonstrate the issue, please make sure it creates all necessary tables, stored procedures etc. Please avoid embedding huge scripts into the report. >P.S. ìîæíî íà ðóññêîì :) No, it's a public system. ------------------------------------------------------------------------ [2006-10-04 15:32:33] eugen at id dot com dot ua I've tried to do the same with PHP 5.2.0RC5-dev - no changes. Memory usage before and after code curl_close($handle); curl_multi_remove_handle($mh, $handle); is the same. Looks like curl doesn't release memory which containing downloaded files. P.S. ìîæíî íà ðóññêîì :) ------------------------------------------------------------------------ [2006-10-04 14:25:03] [EMAIL PROTECTED] Please try using this CVS snapshot: http://snaps.php.net/php5.2-latest.tar.gz For Windows: http://snaps.php.net/win32/php5.2-win32-latest.zip ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at http://bugs.php.net/39037 -- Edit this bug report at http://bugs.php.net/?id=39037&edit=1
