PHP Unable to Allocate Memory – Solutions

apache-2.2linuxopenvz

On my way to the office this morning, every website on our shared VPS started giving the same error (several times, not the typical memory_limit error which is fatal):

Warning: Unknown: Unable to allocate memory for pool. in Unknown on line 0

The shared server is a 64-bit OpenVZ container running cPanel. There are only ~6 VPSes on the host– this is the largest one at only 4GB. The host itself has 24GB RAM. As the below graphs show, the memory usage on the host and VPS are both rather low. CPU Usage/Disk/Host all seem to be normal. RlimitMem was set to 583653034, yet the memory usage is about the same as it usually is.

Apache 2.2, PHP 5.2 (mod_php)

Restarting Apache has corrected the problem for now. However, I'd like to prevent it from happening again and I'm not sure what was limiting the memory. RlimitMem was set to 583653034, yet the memory usage is about the same as it usually is. There's seems to be plenty of memory: what caused this error?

VPS Memory Usage

shared vm memory usage, hovering around 50%

Host Memory Usage

host vm memory usage, used hovering at 20%, cached at 65% until 6AM, where it dropped to ~60%, buffered at ~10%

APC Information

 apc.ttl=0
 apc.shm_size=0
 apc.mmap_file_mask=(blank)

1 Segment(s) with 32.0 MBytes
(mmap memory, pthread mutex locking)

Best Answer

That is definitely the error you get when APC runs out of memory. When I (re)build servers, I often forget to increase this value to 128 M (suitable for my application) and that is the exact error you see.

Related Topic