Edit report at https://bugs.php.net/bug.php?id=63859&edit=1

 ID:                 63859
 Updated by:         pierr...@php.net
 Reported by:        jille at hexon dot cx
 Summary:            Memory leak when reusing curl-handle
-Status:             Open
+Status:             Closed
 Type:               Bug
 Package:            cURL related
 Operating System:   Linux
 PHP Version:        5.4.10
 Block user comment: N
 Private report:     N

 New Comment:

Automatic comment on behalf of pierrick
Revision: 
http://git.php.net/?p=php-src.git;a=commit;h=ac3d227e28056bf5294a8a64e2f41ce2beebaa05
Log: Fixed #63859 Memory leak when reusing curl-handle


Previous Comments:
------------------------------------------------------------------------
[2012-12-27 08:59:22] jille at hexon dot cx

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 this bug report at https://bugs.php.net/bug.php?id=63859&edit=1

Reply via email to