Posted on May 25, 2011
Learn how to setup a live development environment using CodeKit & LESS.
Discover how to add a Media Queries toggle button to your site using jQuery.
Having Magento problems? This solution may help get you up and running again!
Learn how to make Polaroid-style images complete with 3D shadows using only CSS.
Discover how to make your own 3D box using gradients and shadows with the power of CSS.
During the initial discussions it was determined that the “outages” were in fact PHP script errors, which in some server configurations are disabled by default, displaying a rather useless blank white screen instead.
You can easily enable error reporting by using a local PHP override either in a php.ini file or, if that won’t work, setting PHP flags inside your .htaccess file:
php_flag display_errors on
As soon as the errors were being displayed, the problem was indeed revealed as a PHP script error:
Warning: include_once() [function.include-once]: Unable to allocate memory for pool. in /var/www/vhosts/httpdocs/app/Mage.php on line 49
Whilst not immediately useful, it does at least provide some food for Google Recovery in order to begin a search for potential solutions. During this research phase, I actually turned up very little relating to Magento specifically, but there was quite a lot of information in relation to PHP. In many cases, a PHP module known as “APC” kept cropping up. APC (“Alternative PHP Cache”) 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.”.
A quick check of server options using phpinfo(); confirmed that APC was indeed running on the server.
I find the Magento’s cache system quite comprehensive, and set-up correctly should provide an adequate caching system/performance boost for your Magento site. If you have alternative thoughts or can offer more information on how APC can benefit a site, I’d welcome your comments.
So, in this case, I decided to disable the APC module for this particular virtual host on the server (this way it’s still available for other sites running on the server). Disabling the module is very simple, and easy enough to re-enable if you need to do so in the future. It requires another line added to your .htaccess file:
php_flag apc.cache_by_default Off
You can re-run phpinfo(); again to confirm the APC is disabled correctly – and of course, test the live site to see if it fixes your problem!
There have been a real mix of comments regarding the disabling of APC as not really being a solution; I agree it’s definitely a last resort. In my case I was unable to resolve the issues by adjusting the configuration alone – so this I suggest you attempt to fix the error via configuration first (see comments below for suggestions) before resorting to disabling the APC.
Thanks, that helped! I’m still wondering why the messages appeared in the first place though…
Please… this is not a solution, it’s ignorance. Take the time to learn APC. A good start would be this post: http://stackoverflow.com/questions/3723316/warning-require-once-function-require-once-unable-to-allocate-memory-for-po
While I agree with your sentiment, the information in the post is still useful in some cases – say, someone who has a shop who can ill afford it to be offline for hours (even days) on end.
It would also buy some time to correctly rectify the issue whilst keeping the shop online.
I never said my “solution” was the be-all and end-all, it’s just a solution, and is intended to provide a reason for the error and one potential stop-gap solution.
Thanks a lot, i have around 4000 users and very active forum, because of these stupid errors filling whole page was distracting my users, and i followed your instructions and Boom, errors are sweeped away…So thanks a lot..
I agree with K, this really isn’t a very useful post. As you say this is a stop-gap solution that ultimately slows down your system.
A decent opcode cache such as APC does add a significant performance boost for minimal overhead, particularly for large complicated systems and should be used if possible.
The reason that was happening is that APC couldn’t find anywhere to put a new cache entry, this is either because you don’t have enough memory allocated to it or the memory that you have allocated is full. There are 2 php.ini entries I changed to solve the same issue:
1) Increase the size of the cache, we have the ram so this was an option for us.
apc.shm_size = “64MB”
2) Add a timeout so that stale cache entries are re-used.
apc.ttl = “60”;
restart and done.
Also here is a link to a benchmark that clearly shows why it’s better not to just turn it off:
Thanks Sam. I did in fact try to override the PHP config with a local .ini, but the settings didn’t take effect, of course not all hosting solutions allow this.
It’s great to have alternative potential solutions though – hopefully your comment will help someone out before they have to take more drastic steps!
I also agree that disabling APC is not such a great plan, especially when the fix is pretty much as simple as increasing the apc.shm_size in the apc.ini file. (as per the StackOverflow thread).
this is exactly what I was looking for. i added it to my httpd.conf and resolved the issue. totally correct that this is not the solution to the actual problem, but certainly buys me some breathing space – i would imagine the real problem is not allowing enough memory allocation to apc
Hi mate, I trie to change the PHP but this doesn´t work….any suggestions?
You will need to speak to your hosting provider if you are unable to override php.ini locally. Not all hosting solutions allow this.
If you are running on a VPS or dedicated server you will have access to the root php.ini so should make changes there.
“Please… this is not a solution, it’s ignorance” > the post you are refering to on stackoverflow is also false. Using a ttl of 0 will almost disable APC (all cached files deleted when it run out of memory).
Just read the manual
increasing apc.shm_size is not always the solution as the operating system is limiting the real size
in this case you can also increase the number of segments apc.shm_segments
Disabling APC is not a solution APC is increasing efficiency of the computer it is environement-friendly.
Thank you! the information was very useful =)
Just NOTE that you can put that directive in a given .htaccess file , so it is applied only for that folder. Specially usefl to disable APC on Piwik open source statistics.
Thanks Bokan, your solution works for me.
This is not a solution 😛
I’m was having this issue with a Godaddy VPS. A quick fix was to add this line to my php script:
the PHP ini_set(‘apc.cache_by_default’,0);
Not “ideal” but it does work.
Thanks to sam, your advice seem to have solved our problems on magento (bitnami distribution for linux).
[…] http://toolboxdigital.com/2011/05/fixing-unable-to-allocate-memory-for-pool-php-error-in-magento/ […]
My site was working on linux but i moved website to window server. it does not open . got this error “The server at mysite.com is taking too long to respond” and i checked system log it is logging this error.
2013-10-04T14:31:33+00:00 ERR (3): Warning: include(): Unable to allocate memory for pool. in /home/www/mysite/public_html/lib/Varien/Autoload.php on line 93
it is still looking for linux path on window platform. how can it be resolved ? any help would be greatly appreciated.
yeah,Indeed it is!
Great trick 🙂
Thanks a lot for this post. It saved my day
i tried it and it actually works.
Thanks a lot. 🙂
Thanks , I have just bern looking for information about this subject for a long time and yours is thee greateest I have fkund out so far.
However, what concerning the bottom line? Are youu certain concerning the source?
Mail (will not be published) *
Your comment *
I consent to Toolbox Digital collecting and storing my data from this form, as detailed in the Privacy Notice.
Previous: Making Responsive Web Design Optional
Next up: CSS3 Experiments #2: Polaroids
.htaccess Made Easy
by JEFF STARR
Buy Now »
Hardboiled Web Design
by ANDY CLARKE