Re: mmap in php_passthru_fd in file.c ?
| From: | Sterling Hughes | Date: | Thu, 17 May 2001 16:49:34 +0000 |
| Subject: | Re: mmap in php_passthru_fd in file.c ? | ||
| References: | 1 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-55696@lists.php.net to get a copy of this message | ||
Rasmus Lerdorf wrote:
If a system has mmap() a readfile() will mmap the entire file to memory and then dump that while without mmap it will read it one block at a time. That's a siginificant memory difference and one that may not be expected. Obviously the mmap will be faster, but if as in bug #10701, someone is adding headers or doing something else to really large files, things are going to break. Since readfile() already has an opotional argument I think the right approach is a separate function that turns the mmap off and reads the file block by block. fpassthru() doesn't have an optional arg, so we could toggle it there for that function. Comments?Well, out of the solutions, I think the optional argument to fpassthru() would be the best. However, why not, as you stated in response to the bug report, read the file with a custom function and output it, therefore avoiding the mmap() as well? -Sterling