Apache cannot fork: cannot allocate memory
It sounds like you are hitting resource limits. Look at pam_limits.so and /etc/security/limits.conf
. These allow an administrator to set explicit limits on the resources a user can use so that one user can't hog all the system resources. If Apache is hitting a limited specified by this, it will return an error like above even though there are plenty of resources other users can use. There is also the limit
or ulimit
command in most shells, but I don't think that's the problem.
Related videos on Youtube
Ryan Walkowski
Updated on September 18, 2022Comments
-
Ryan Walkowski over 1 year
I am running
apache
on Fedora withmod_perl
. The server forks a process to send an email frequently - and the fork exits.Suddenly, I got:
Cannot fork: Cannot allocate memory
. There was plenty of free memory (I did not look too closely, but there was more memory free than in use), not too manyapache
processes running - 10?, low cpu usage, close to 0. Restarting the server httpd graceful resolved the issue.What would cause something like this? Is it possible that I got into some kind of a state where the problem was allocating too many processes in the system - and with dropping load failed to recover?
Unfortunately I do not have too much info as I was panicking and trying to get the site up instead of running diagnostics. :-) So my question is very general: is there anything that's not obvious that would create this behavior when too many processes are allocated? Anything specific to forking from within apache? etc
Thank you!
-
Coren about 12 yearscan you be more precise about this ? how much is "plenty of free memory" ? how much is "not too many processes running" ? Did you run an
htop
-like tool to see what consumes most of the memory ? -
Nikhil Mulley about 12 yearsYes, can you be also generous in sharing your apache config (mostly performance tuning specific)
-
phemmer about 12 yearscan you provide the output of
sysctl -a 2>/dev/null | grep '^vm'
andcat /proc/meminfo
. Preferably while the issue is occurring. If this is not possible, still post, there may be something blatantly obvious. -
Smiley about 12 yearsAre you running this on any virtual machine? I have a similar problem, although with another software.
-