From: [EMAIL PROTECTED]
Operating system: SunOS 5.8
PHP version: 4.1.2
PHP Bug Type: Sockets related
Bug description: fread function leaks memory when reading from socket
It seems that fread command leaks memory when data is
read from a socket. It does not leak memory if it reads
from open file descriptor. The speed of the process increse is as fast as
the data flow, i.e. all bytes
which are read leaks!
Here is a program that shows the problem. We have a file
server in the port 9229. When connection is opened there
and about 250 MB zip file is requested, the process dies
after it has received 8 MB of data. If the file is read
from an open file, the process size does not increse at
all, and it works perfectly.
<?php
$len=248532882;
header("Content-Type: application/octet-stream");
header("Content-Disposition: attachment; filename=file.zip");
header("Content-Length: $len");
$pkg_size=1024;
if(1) {
$sock=fsockopen("localhost", 9229) or die ("Cannot open socket");
fputs($sock, "GET file.zip\r\n");
}
else {
$sock=fopen("file.zip", "r");
}
while(!feof($sock)) {
$recv_amount=(($len > $pkg_size) ? ($pkg_size): ($len));
print fread($sock, $recv_amount);
$len=$len-$recv_amount;
if($len<1) break;
}
flush();
fclose($sock);
?>
Here is the configuration command of PHP 4.1.2 we are
using, as reported by the phpinfo().
'./configure' '--with-apache=../apache_1.3.23'
'--with-ldap=/data/usr/iPlanet/ldapcsdk414' '--prefix=/data'
'--enable-memory-limit'
--
Edit bug report at http://bugs.php.net/?id=16148&edit=1
--
Fixed in CVS: http://bugs.php.net/fix.php?id=16148&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=16148&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=16148&r=needtrace
Try newer version: http://bugs.php.net/fix.php?id=16148&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=16148&r=support
Expected behavior: http://bugs.php.net/fix.php?id=16148&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=16148&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=16148&r=submittedtwice