ID:               40257
 User updated by:  angry dot slipper at gmail dot com
 Reported By:      angry dot slipper at gmail dot com
 Status:           Bogus
 Bug Type:         Streams related
 Operating System: Linux Fedora 4
 PHP Version:      5.2.1RC4
 New Comment:

I have a daemon written in PHP which connects to remote servers via
fopen() sending POST data. 
How do I clean up RAM? I need this daemon to run for months without
restarting it.

PS: I can’t use CURL, cause I need to read from stream with
dynamically changed buffer.


Previous Comments:
------------------------------------------------------------------------

[2007-01-27 15:32:43] [EMAIL PROTECTED]

All memory leaks are reported automatically.
stream_context_create() creates stream context and adds it to the
resource list, which is freed on shutdown.
You cannot free the context with unset(), because there might be open
streams using it.

------------------------------------------------------------------------

[2007-01-27 15:25:29] angry dot slipper at gmail dot com

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

Reply via email to