Thinking about this more, the question really is: why is Apache putting an in-progress upload in memory instead of on disk? I should be able to upload a file that's larger than the total memory available to the server.
PHP never enters the equation, as the upload never finishes, and Apache dies before it can pass the file to PHP.
Very odd. I've been googling for hours, to no avail.
I have a VPS with 512 MB RAM, and I'm trying to upload files that are between 100-250 MB. Files up to about 100 MB work fine, but anything over and I run into memory problems.
Here's the output from
top as I try to upload a 130 MB file, immediately before PID 18367 is killed:
top - 09:43:06 up 6 days, 9:31, 1 user, load average: 0.00, 0.00, 0.00 Tasks: 51 total, 1 running, 50 sleeping, 0 stopped, 0 zombie Cpu(s): 0.2% us, 0.1% sy, 0.0% ni, 99.8% id, 0.0% wa, 0.0% hi, 0.0% si Mem: 916144k total, 916144k used, 0k free, 0k buffers Swap: 0k total, 0k used, 0k free, 0k cached PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 18367 apache 16 0 721m 393m 2288 S 0 44.0 0:01.90 httpd
Somehow it's using 393 MB of memory for a 130 MB file? (Not to mention, only about 80% of the file had uploaded.) I can't imagine what httpd is doing with all of that space.
Looking in the apache error log, I see:
[Tue Feb 01 09:43:07 2011] [error] (12)Cannot allocate memory: fork: Unable to fork new process [Tue Feb 01 09:43:17 2011] [notice] child pid 18367 exit signal Segmentation fault (11)
I'm not sure if this a limitation of the software stack (CentOS, Apache, and PHP through mod_fcgid), or a misconfiguration of either Apache or PHP.
I do use the following mod_fcgid directive in my vhost.conf, but to little effect:
Are there similar apache configuration values that I ought to tune?
Thanks for your consideration.