RE: [PHP-DEV] readfile() memory usage

From: Date: Tue, 01 May 2012 08:44:01 +0000
Subject: RE: [PHP-DEV] readfile() memory usage
References: 1 2 3 4 5 6 7  Groups: php.internals 
Request: Send a blank email to internals+get-60384@lists.php.net to get a copy of this message
> Hi Larry, > > > 4) So given #2 and #3, the "readfile() will kill your memory, don't use it" > > line is a persistent urban legend that belongs on Snopes as debunked. > > Looping on fread() for performance is a red herring. > > I implemented this earlier this very year to avoid memory issues (a > quick look at project history shows me working on it in January). The > difference between using readfile, and some convoluted method from the > documentation comments was clear and immediate: corrupted download > with out of memory error in the logs, to things working just fine. > > Let me re-create with a simple test script and share my server details > before we call snopes :) Are you sure that you are *not* using ob_start()/ob_flush()/... (output buffering)? If this is the case, readfile writes to the output, but buffers everything in memory, as the PHP output buffering is active? Uwe

« previous php.internals (#60384) next »