ID: 29940 Updated by: [EMAIL PROTECTED] Reported By: tcarroll at chimesnet dot com -Status: Open +Status: Bogus Bug Type: Output Control Operating System: linux 2.6.5; glibc 2.3.3 PHP Version: 4.3.8 New Comment:
Please do not submit the same bug more than once. An existing bug report already describes this very problem. Even if you feel that your issue is somewhat different, the resolution is likely to be the same. Thank you for your interest in PHP. Duplicate of #29922. Previous Comments: ------------------------------------------------------------------------ [2004-09-01 23:59:03] tcarroll at chimesnet dot com Description: ------------ If output buffering is used and a large file is opened and the resulting handle is passed to fpassthru, memory exhaustion occurs. The optimization in _php_stream_passthru mmaps the entire file into the address space. During the PHPWRITE call sequence, an output buffer is allocated the size of the mmap'ed file. If the file is large, a large allocation occurs. Semantically, fpassthru should not cause memory exhaustion. Generally, large writes to buffered IO should generate several flushes to the underlying IO device instead of allocating one large buffer to store the contents. This limits the applications of fpassthru to where the file size is known before hand and where the size is smaller than memory_limit or available memory. This was earlier reported as #20772 Reproduce code: --------------- Create a file larger than memory_limit or available memory memory_limit = 8M dd if=/dev/zero of=bigfile bs=1M count=128 <?php $fp = fopen('./bigfile','r'); fpassthru($fp); ?> Expected result: ---------------- The entire output of the file Actual result: -------------- No output PHP Fatal error: Allowed memory size of 8388608 bytes exhausted (tried to allocate 134213632 bytes) in /home/tcarroll/public_html/passthru.php on line 14 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=29940&edit=1