Memory limit issue (malloc) for PHP script under Apache
o.greve at axis.nl
Wed Dec 7 06:19:00 PST 2005
A colleague of mine has run into a weird issue, for which we hope
someone knows a solution (or otherwise: if someone knows there's no
(easy) solution, that's also good to know.
The issue: when running a script that will consume a large amount of
memory (under FreeBSD 5.2.1-release i386, with custom kernel, with
Apache 1.3.34_2, PHP 4.4.1 as mod_php4); Apache seems to deschedule the
script in question as soon as it starts to consume over more or less
512MB of memory; the machine has 1GB of memory, and at the moment of
running the script the rest of the machine is pretty much idle.
The returned error in httpd-error.log is:
httpd in malloc(): error: allocation failed
We tried fiddling around with the php.ini and httpd.conf files, after
Googling and trying stuff like RlimitMem (which apparently only seems to
have effect for the CGI version of PHP and not the Mod version), but all
to no avail.
The script that needs to be run will not be that easy to rewrite such
that it'll use less memory; so we're hoping there's an easy trick to
allow Apache to use more memory (say 900 MB).
Does anyone know how to achieve this?
Note: I'm aware that it would be better to tune the script, but as this
is a one time brute force script; a quick work-around would be nice. :)
Tnx in advance, and cheers!
PS: the command "limit -h" shows a datasize limit of 524000 bytes; this
seems to be the limit that applies to Apache as well. Yet, changing to
the csh and trying to set it to "unlimited" doesn't do any magic either
and still doesn't supercede the above limit (unless I missed something)...
More information about the freebsd-questions