|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2002-03-18 15:15 UTC] wez@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Oct 26 09:00:01 2025 UTC |
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'