From: humbads at alum dot mit dot edu
Operating system: FreeBSD 6.2, Windows XP SP3
PHP version: 5.2.6
PHP Bug Type: cURL related
Bug description: reusing a curl handle leaks memory
Description:
------------
Reusing a curl handle for multiple requests leaks memory. It leaks about
100 bytes per request. This is a problem when making a large number of
requests using the same handle. Libcurl documentation says to always reuse
the handle when possible in order to reuse connections. The bug occurs on
Windows XP/IIS and Apache/FreeBSD 6.2.
Reproduce code:
---------------
<?php
// Reuse curl handle memory leak test
$ch = curl_init();
$startmem = memory_get_usage();
for($i = 0; $i < 100; $i++) {
$fp = fopen('/dev/null', "w");
curl_setopt($ch, CURLOPT_URL,
'http://debug.atensoftware.com/r.php?echo='.rand());
curl_setopt($ch, CURLOPT_FILE, $fp);
curl_exec($ch);
fclose($fp);
unset($fp);
print "$i-mem: ".(memory_get_usage() - $startmem)." bytes\n";
}
?>
Expected result:
----------------
The memory usage should not increase after each request.
--
Edit bug report at http://bugs.php.net/?id=45161&edit=1
--
Try a CVS snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=45161&r=trysnapshot52
Try a CVS snapshot (PHP 5.3):
http://bugs.php.net/fix.php?id=45161&r=trysnapshot53
Try a CVS snapshot (PHP 6.0):
http://bugs.php.net/fix.php?id=45161&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=45161&r=fixedcvs
Fixed in release:
http://bugs.php.net/fix.php?id=45161&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=45161&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=45161&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=45161&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=45161&r=support
Expected behavior: http://bugs.php.net/fix.php?id=45161&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=45161&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=45161&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=45161&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=45161&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=45161&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=45161&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=45161&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=45161&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=45161&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=45161&r=mysqlcfg