I have been getting this error in my server log file.
[Sun Jan 29 00:22:43.570300 2017] [mpm_prefork:error] [pid 1205] (12)Cannot allocate memory: AH00159: fork: Unable to fork new process
[Sun Jan 29 00:22:53.742820 2017] [mpm_prefork:error] [pid 1205] (12)Cannot allocate memory: AH00159: fork: Unable to fork new process
[Sun Jan 29 00:23:03.771702 2017] [core:notice] [pid 1205] AH00051: child pid 22134 exit signal Aborted (6), possible coredump in /etc/apache2
[Sun Jan 29 00:23:03.876081 2017] [core:notice] [pid 1205] AH00051: child pid 22135 exit signal Aborted (6), possible coredump in /etc/apache2
[Sun Jan 29 00:23:04.899489 2017] [mpm_prefork:error] [pid 1205] (12)Cannot allocate memory: AH00159: fork: Unable to fork new process
[Sun Jan 29 00:23:14.931272 2017] [mpm_prefork:error] [pid 1205] (12)Cannot allocate memory: AH00159: fork: Unable to fork new process
[Sun Jan 29 00:23:24.965639 2017] [mpm_prefork:error] [pid 1205] (12)Cannot allocate memory: AH00159: fork: Unable to fork new process
[Sun Jan 29 00:23:35.031174 2017] [mpm_prefork:error] [pid 1205] (12)Cannot allocate memory: AH00159: fork: Unable to fork new process
help to solving out the issue.
The cannot allocate memory
error usually points to an Out Of Memory (OOM) error.
This can happen very often on the smaller EC2 Instances, e.g. if you haven't tuned the maximum memory your apps can request from the operating system.
Your app (in this case Apache) attempts to allocate some memory (which it expects it should be able to request, based on its config) and the OS simply doesn't have enough to give it.
Some common solutions:
Upgrade to a larger EC2 instance, with, well, simply more memory available. This clearly does not solve the problem's root cause, but - given low enough traffic - it could even cause it to stop appearing altogether.
This is only an option if your budget allows it, of course...
To be more precise: Consider adding swpa
As to how, the below creates a 4GB swapfile:
sudo dd if=/dev/zero of=/var/swapfile bs=1M count=4096
sudo chmod 600 /var/swapfile
sudo mkswap /var/swapfile
sudo swapon /var/swapfile
Word of warning: swap, when used inappropriately, can easily lead into nasty situations, such as thrashing
You'll want to read up on Apache Performance Tuning
Hope this helps!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With