php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #20913 emalloc / erealloc FATAL errors
Submitted: 2002-12-09 18:45 UTC Modified: 2002-12-09 22:30 UTC
From: matt8192 at yahoo dot com Assigned:
Status: Not a bug Package: Reproducible crash
PHP Version: 4.2.3 OS: Solaris 8
Private report: No CVE-ID: None
 [2002-12-09 18:45 UTC] matt8192 at yahoo dot com
When I use fpassthru to send large media files (100-500 
MB) to the user, it sometimes causes that Apache thread to 
crash, and it's taken down the entire Solaris box (!) two 
or three times. 
 
Apache's error log entries look like this: 
FATAL:  emalloc():  Unable to allocate 205164673 bytes 
FATAL:  erealloc():  Unable to allocate 205166593 bytes 
FATAL:  erealloc():  Unable to allocate 205166593 bytes 
 
The box has a gig of RAM. Does fpassthru not work with 
large files? Is there a better method? 
 
Thanks 
-Matt 

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-12-09 20:25 UTC] iliaa@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

Well, what if 5 users retrieve the file all your ram will be used up and the 6ht users will get the error you see here. For performance reasons fpassthru() uses mmap, which maps the entire file to memory. If you need to send large files >10megs to the user, use fread() and read the file in smaller chunks, 1-2 megs, that should prevent memory issues and maintain reasonable level of performance.
 [2002-12-09 22:30 UTC] matt8192 at yahoo dot com
okay, thank you for the help!  
  
I double-checked PHP documentation and it doesn't mention  
anything about large files or memory mapping methods in 
fpassthru. Perhaps it would be worth adding a blurb?  
  
thanks again, 
-Matt
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Apr 24 13:01:29 2024 UTC