From: jille at hexon dot cx
Operating system: Linux
PHP version: 5.4.10
Package: cURL related
Bug Type: Bug
Bug description:Memory leak when reusing curl-handle
Description:
------------
PHP (or libcurl, I'm afraid I don't know where exactly the problem lies)
seems to leak memory when using the same curl-handle for multiple
requests.
The test script below reports the same memory_get_usage()-value for the
first 300 requests and a 25% increase after but top(1) reports the memory
grows up to 100MB when the script is done.
Uncommenting the resetting of CURLOPT_POSTFIELDS doesn't seem to help.
Uncommenting the recreation of $ch prevents the memory from being leaked.
Test script:
---------------
<?php
$ch = curl_init('http://some-domain.com/dump.html');
for($i = 0; 1000 > $i; $i++) {
# $ch = curl_init('http://some-domain.com/dump.html');
$post = array();
$post['data'] = base64_encode(str_repeat(hash('sha256',
uniqid()),
1000));
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_exec($ch);
# curl_setopt($ch, CURLOPT_POSTFIELDS, '');
if($i % 100 == 0) {
var_dump(memory_get_usage(true));
}
}
?>
--
Edit bug report at https://bugs.php.net/bug.php?id=63859&edit=1
--
Try a snapshot (PHP 5.4):
https://bugs.php.net/fix.php?id=63859&r=trysnapshot54
Try a snapshot (PHP 5.3):
https://bugs.php.net/fix.php?id=63859&r=trysnapshot53
Try a snapshot (trunk):
https://bugs.php.net/fix.php?id=63859&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=63859&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=63859&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=63859&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=63859&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=63859&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=63859&r=support
Expected behavior: https://bugs.php.net/fix.php?id=63859&r=notwrong
Not enough info:
https://bugs.php.net/fix.php?id=63859&r=notenoughinfo
Submitted twice:
https://bugs.php.net/fix.php?id=63859&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=63859&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=63859&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=63859&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=63859&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=63859&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=63859&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=63859&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=63859&r=mysqlcfg