What is causing Unable to allocate memory for pool in PHP?
Probably is APC related.
For the people having this problem, please specify you .ini settings. Specifically your apc.mmap_file_mask setting.
For file-backed mmap, it should be set to something like:
apc.mmap_file_mask=/tmp/apc.XXXXXX
To mmap directly from /dev/zero, use:
apc.mmap_file_mask=/dev/zero
For POSIX-compliant shared-memory-backed mmap, use:
apc.mmap_file_mask=/apc.shm.XXXXXX
Symfony Unable to allocate memory for pool
This error is usually related to Alternative PHP Cache (APC) related which is a free and open opcode cache for PHP. Its goal is to provide a free, open, and robust framework for caching and optimizing PHP intermediate code. Edit /etc/php.d/apc.ini, enter:
# vi /etc/php.d/apc.ini
Make sure the mktemp-style file_mask to pass to the mmap module is correct and valid one:
apc.mmap_file_mask=/tmp/apc.XXXXXX
Next make sure the size of each shared memory segment, with M/G suffix is set correct as per your requirements. In my case it was set to 8M:
apc.shm_size=96M
You need to adjust the number of seconds a cache entry is allowed to idle in a slot in case this cache entry slot is needed by another entry:
apc.ttl=3600
The number of seconds a user cache entry is allowed to idle in a slot in case this cache entry slot is needed by another entry:
apc.user_ttl=3600
The number of seconds that a cache entry may remain on the garbage-collection list.
Save and close the file. Make sure you adjust the values as per your requirements. Restart the Apache 2 web server:
# service httpd restart
Hide error unable to allocate memory for pool
You can hide the PHP error messages by setting the environment in index.php to testing or production. This turns off all PHP error reporting.
define('ENVIRONMENT', 'production');
The templates for the error messages are in application/errors - you can change the appearance of the messages here.
require_once: cannot allocate memory
It turns out this was a problem with my windows share. Perhaps because Windows 7 is a client OS, it is not tuned to serve large amounts of files frequently (which is happening in my case).
To fix, set the following keys in the registry:
HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management\LargeSystemCache
to 1
HKLM\SYSTEM\CurrentControlSet\Services\LanmanServer\Parameters\Size
to 3
I have been running my setup with these new settings for about a week and have not encountered any memory allocation errors since making the change.
Related Topics
Generating Cryptographically Secure Tokens
How to Programmatically Login/Authenticate a User
What Do Strict Types Do in PHP
Mock Private Method With PHPunit
Is There Any Particular Difference Between Intval and Casting to Int - '(Int) X'
Replace Last Occurrence of a String in a String
Which Is Faster in PHP, $Array[] = $Value or Array_Push($Array, $Value)
Convert Utf8-Characters to Iso-88591 and Back in PHP
Adding Minutes to Date Time in PHP
Difference Between Method Calls $Model-≫Relation(); and $Model-≫Relation;
Error 330 (Net::Err_Content_Decoding_Failed):
Variable-Length Lookbehind-Assertion Alternatives For Regular Expressions
What Is the Default Lifetime of a Session
How to Select First 10 Words of a Sentence
How to Do Left Join in Doctrine
Utility of Http Header "Content-Type: Application/Force-Download" For Mobile
Assigning the Return Value of New by Reference Is Deprecated