ID: 29159
Updated by: [EMAIL PROTECTED]
Reported By: victor-php at boivie dot com
-Status: Open
+Status: Bogus
Bug Type: Filesystem function related
Operating System: FreeBSD 4.7
PHP Version: 5.0.0
New Comment:
When you have output buffering enabled, all your output will be
buffered.
Turn off output buffering when you are spitting out large files and
your problem will go away.
Previous Comments:
------------------------------------------------------------------------
[2004-07-14 20:18:21] victor-php at boivie dot com
Description:
------------
victor:~> php -v
PHP 5.0.0RC2 (cgi) (built: Apr 30 2004 08:15:25)
(oh well, this issue still exists in 5.0.0)
victor:~> grep output /usr/local/lib/php.ini
<snip>
output_buffering = 4096
<snip>
output_handler =
<snip>
zlib.output_compression = Off
victor:~> ls -l test.fil
-rw-r--r-- 1 root wheel 734939136 Oct 14 2003 test.fil
--------------------------------
As the results shows, PHP tries to allocate the whole file in memory
which is bad. I thought php_stream_passthru used a small buffer and
that it didn't allocate the whole file, but I'm not familiar with the
PHP source code.
Reproduce code:
---------------
<?php
readfile("test.fil");
?>
Expected result:
----------------
A lot of file data in the browser window (the file contents)
Actual result:
--------------
PHP Fatal error: Out of memory: cannot allocate 734941208 bytes! in
/usr/home/victor/foo.php on line 2
Content-type: text/html
X-Powered-By: PHP/5.0.0RC2
<br />
<b>Fatal error</b>: Out of memory: cannot allocate 734941208 bytes! in
<b>/usr/home/victor/foo.php</b> on line <b>2</b><br />
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=29159&edit=1