From:             
Operating system: LINUX
PHP version:      5.3.8
Package:          Streams related
Bug Type:         Bug
Bug description:memory leak with create context

Description:
------------
hi, when i create a context inside a function i see a memory leak, but when
i create it in the main source code line, i don´t see it...
please check the script..

i think the problem is something that don´t leave memory get back when
destroying context variable

Test script:
---------------
memory leak:
<?php
function g(){
       
$context=stream_context_create(array('http'=>array('timeout'=>1)));
        $ret=file_get_contents('http://172.17.0.5/not_found',0,$context);
        unset($context);
        return($ret);
}
        $base=memory_get_usage();
        while(1){
                g();
                usleep(50000);
                echo    (memory_get_usage()-$base)."\n";
// memory get bigger and bigger here....
        }
?>

memory leak too:
<?php
        $base=memory_get_usage();
        while(1){
                $context=
stream_context_create(array('http'=>array('timeout'=>1)));
               
$ret=file_get_contents('http://172.17.0.5/not_found',0,$context);
                usleep(50000);unset($ret,$context);
                echo    (memory_get_usage()-$base)."\n";
// memory get bigger and bigger...
        }
?>


nice:
<?php
        $base=memory_get_usage();
        $context=
stream_context_create(array('http'=>array('timeout'=>1)));
        while(1){
               
$ret=file_get_contents('http://172.17.0.5/not_found',0,$context);
                usleep(50000);unset($ret);
                echo    (memory_get_usage()-$base)."\n";
// memory is nice here...
        }
?>



Expected result:
----------------
NICE:
Warning...
3552
Warning...
3552
Warning...
3552
Warning...
3552
Warning...
3552
Warning...
3552


MEMORY LEAK:
Warning...
40120
Warning...
41344
Warning...
42568
Warning...
43792


Actual result:
--------------
well i think that others fields explain...

MEMORY LEAK:
Warning...
40120
Warning...
41344
Warning...



(+- 1224 per while interaction)

i don´t know how to solve this, unset don´t work, =null don´t work, and
i don´t find a function to destroy contexts...

-- 
Edit bug report at https://bugs.php.net/bug.php?id=60570&edit=1
-- 
Try a snapshot (PHP 5.4):            
https://bugs.php.net/fix.php?id=60570&r=trysnapshot54
Try a snapshot (PHP 5.3):            
https://bugs.php.net/fix.php?id=60570&r=trysnapshot53
Try a snapshot (trunk):              
https://bugs.php.net/fix.php?id=60570&r=trysnapshottrunk
Fixed in SVN:                        
https://bugs.php.net/fix.php?id=60570&r=fixed
Fixed in SVN and need be documented: 
https://bugs.php.net/fix.php?id=60570&r=needdocs
Fixed in release:                    
https://bugs.php.net/fix.php?id=60570&r=alreadyfixed
Need backtrace:                      
https://bugs.php.net/fix.php?id=60570&r=needtrace
Need Reproduce Script:               
https://bugs.php.net/fix.php?id=60570&r=needscript
Try newer version:                   
https://bugs.php.net/fix.php?id=60570&r=oldversion
Not developer issue:                 
https://bugs.php.net/fix.php?id=60570&r=support
Expected behavior:                   
https://bugs.php.net/fix.php?id=60570&r=notwrong
Not enough info:                     
https://bugs.php.net/fix.php?id=60570&r=notenoughinfo
Submitted twice:                     
https://bugs.php.net/fix.php?id=60570&r=submittedtwice
register_globals:                    
https://bugs.php.net/fix.php?id=60570&r=globals
PHP 4 support discontinued:          
https://bugs.php.net/fix.php?id=60570&r=php4
Daylight Savings:                    https://bugs.php.net/fix.php?id=60570&r=dst
IIS Stability:                       
https://bugs.php.net/fix.php?id=60570&r=isapi
Install GNU Sed:                     
https://bugs.php.net/fix.php?id=60570&r=gnused
Floating point limitations:          
https://bugs.php.net/fix.php?id=60570&r=float
No Zend Extensions:                  
https://bugs.php.net/fix.php?id=60570&r=nozend
MySQL Configuration Error:           
https://bugs.php.net/fix.php?id=60570&r=mysqlcfg

Reply via email to