ID: 33127
Updated by: [EMAIL PROTECTED]
Reported By: joropito at ciudad dot com dot ar
-Status: Open
+Status: Bogus
Bug Type: Sockets related
Operating System: FreeBSD 5.3/4
PHP Version: 5.0.4
New Comment:
Yes, this is just how resources in PHP works. No bug here.
Previous Comments:
------------------------------------------------------------------------
[2005-05-25 00:56:43] joropito at ciudad dot com dot ar
This example code show initial and final memory usage. I'm wrong? It
doesnt free all resources.
My cli application makes an infitite loop, and every time it tries to
use network resources, memory usage increases and after some time no
more memory available.
<?php
echo memory_get_usage()."\n";
$db = mysql_connect("dbhost", "dbuser", "dbpass");
mysql_close($db);
unset($db)
echo memory_get_usage()."\n";
?>
------------------------------------------------------------------------
[2005-05-24 22:27:19] [EMAIL PROTECTED]
How are you measuring this?
------------------------------------------------------------------------
[2005-05-24 18:10:34] joropito at ciudad dot com dot ar
It's related to any network interaction.
Reproducible with
mysql_connect
file_get_contents (http wrapper)
fsockopen
------------------------------------------------------------------------
[2005-05-24 16:50:50] joropito at ciudad dot com dot ar
Reproducible under php-4.3.9
Smaller reproducible code
<?php
system("/bin/ps -l -p ".posix_getpid());
$fd = fsockopen("www.yahoo.com", 80, $errno, $errstr, 3);
system("/bin/ps -l -p ".posix_getpid());
if($fd) fclose($fd);
system("/bin/ps -l -p ".posix_getpid());
?>
------------------------------------------------------------------------
[2005-05-24 16:43:21] joropito at ciudad dot com dot ar
Description:
------------
I see that fsockopen() causes a memory leak although of closing
filedescriptor.
Reproduce code:
---------------
system("/bin/ps -maxwvj -p ".posix_getpid());
$fd = fsockopen("www.yahoo.com", 80, $errno, $errstr, 3);
system("/bin/ps -maxwvj -p ".posix_getpid());
if($fd) {
$out = "GET / HTTP/1.1\nHost: www.yahoo.comConnection: Close\n\n";
fwrite($fd, $out);
$line = "";
while (!feof ($fd)) {
$lastline = fgets($fd);
$line .= $lastline;
if(ereg("Content-Type: text/html", $lastline)) { break; }
}
fclose($fd);
echo $line;
}
system("/bin/ps -maxwvj -p ".posix_getpid());
sleep(5);
Expected result:
----------------
You will see after issue fsockopen() memory usage rises, and if you
issue fclose() does not free memory.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=33127&edit=1