From:             angry dot slipper at gmail dot com
Operating system: Linux Fedora 4
PHP version:      5.2.1RC4
PHP Bug Type:     Streams related
Bug description:  stream_context_create() causes memory leaks

Description:
------------
stream_context_create() causes memory leaks.

PHP version is actualy 5.2.1RC5 - latest available.

Reproduce code:
---------------
#!/www/httpd/php/cli -ne
<?php

$postdata=array_fill(0,128,"blah");
for ($a=0;$a<100;$a++){
        $options=array('http'=>array(
                                'method'=>"POST",
                                'request_fulluri'=>"POST http://www.google.com 
HTTP/1.0",
                                'header'  => 'Content-type: 
application/x-www-form-urlencoded',
                                'content' => $postdata
                )
        );
        $context=stream_context_create($options);
        unset($context,$options);
        echo "current: ",memory_get_usage()," delta:
",(memory_get_usage()-$prev)."\n";
        $prev=memory_get_usage();
}
?>

Expected result:
----------------
"current: 74496 delta: 0" line repeated.

Actual result:
--------------
current: 87368 delta: 87368
current: 100008 delta: 12520
<...many lines here>
current: 1319348 delta: 12440

As you can clearly see each iteration eatch 12kb of RAM, which it
shouldn't.

If you comment the

$context=stream_context_create($options);

line out, delta in the example above will always be at 0.

-- 
Edit bug report at http://bugs.php.net/?id=40257&edit=1
-- 
Try a CVS snapshot (PHP 4.4): 
http://bugs.php.net/fix.php?id=40257&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): 
http://bugs.php.net/fix.php?id=40257&r=trysnapshot52
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=40257&r=trysnapshot60
Fixed in CVS:                 http://bugs.php.net/fix.php?id=40257&r=fixedcvs
Fixed in release:             
http://bugs.php.net/fix.php?id=40257&r=alreadyfixed
Need backtrace:               http://bugs.php.net/fix.php?id=40257&r=needtrace
Need Reproduce Script:        http://bugs.php.net/fix.php?id=40257&r=needscript
Try newer version:            http://bugs.php.net/fix.php?id=40257&r=oldversion
Not developer issue:          http://bugs.php.net/fix.php?id=40257&r=support
Expected behavior:            http://bugs.php.net/fix.php?id=40257&r=notwrong
Not enough info:              
http://bugs.php.net/fix.php?id=40257&r=notenoughinfo
Submitted twice:              
http://bugs.php.net/fix.php?id=40257&r=submittedtwice
register_globals:             http://bugs.php.net/fix.php?id=40257&r=globals
PHP 3 support discontinued:   http://bugs.php.net/fix.php?id=40257&r=php3
Daylight Savings:             http://bugs.php.net/fix.php?id=40257&r=dst
IIS Stability:                http://bugs.php.net/fix.php?id=40257&r=isapi
Install GNU Sed:              http://bugs.php.net/fix.php?id=40257&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=40257&r=float
No Zend Extensions:           http://bugs.php.net/fix.php?id=40257&r=nozend
MySQL Configuration Error:    http://bugs.php.net/fix.php?id=40257&r=mysqlcfg

Reply via email to