Last night when I was moderating some comments on TechPP, I was shocked to see an error page instead of the admin panel dashboard. The error read something like this -
PHP Fatal error: Out of memory (allocated 49545216) (tried to allocate 77824 bytes) in /home/xxxxx/public_html/xyz/admin.php(1758) on line 40
The first thing I could think of was to restart the Apache httpd service. This immediately solved the issue. but I knew this is not a permanent fix for the issue. When I researched further, I got to know that the error comes when certain PHP scripts require more memory than PHP was allowed by default.
So the solution is to increase the memory allocated for PHP. How to do that? There are 4 possible ways -
1. Try looking for the php.ini file. You might find some redundant php.ini files, so make sure you have got the one which is actually being read by PHP. o be sure, create a new php file in your root folder, say “check.php” and have phpInfo(); within the php open and close tags. Execute this file to get the information on where the php.ini is residing. Normally it will be in /usr/local/lib/php.ini
Open the php.ini file in a text editor like TextPad (not in Notepad) and change the values for memory_limit. By default you should see memory_limit = 8M. Try changing it to 12M. If it doesn’t work, increase it to 16M or even 24M and so on.
2. In case you can’t find the php.ini file or do not have access to it, then open up the file which was throwing the error (admin.php in my case) and add a line below just after ini_set(’memory_limit’, ‘12M’);
3. You can even consider adding a line in .htaccess file which will resolve the issue.
php_value memory_limit 32M
4. Or else, Try adding this line to your wp-config.php file:
Increasing memory allocated to PHP
define('WP_MEMORY_LIMIT', '32M');
If none of the above things solve your issue, then talk to you host. If you have a host like Knownhost who is fast and knows what needs to be done, you do not have to worry much.
Note: I am now worrying on which PHP script required an increase in memory allocation. The analysis won’t be so easy though.
Image Courtesy: Clarkandransom

Nice info – I’m currently trying to work around a memory allocation error and you have some ideas I haven’t found on other sites, I’ll be giving these ideas a try shortly
Hey, i think i also seen this error. but, it was due to plugin not compatible with 2.8. but it is good that you learnt something corrected it and sharing here.
“So the solution is to increase the memory allocated for PHP”
Isn’t it a better solution to try and find out what causes PHP to use so much memory? And fix that instead?
@Vincent,
that’s not something easy. There is no easy way to find out which process/plugin is taking in extra memory. In case it goes beyond a point, you can start disabling plugins one-by-one to see if it improves memory consumption.
@Raju
I agree with Vincent. Throwing more memory at something that has memory leaks can only make the problem go away for a while. It will still be there and may come back.
Best thing to do is to try and get rid of the underlying issue.
I am having the same error issue, I don’t have shell access to my site, but have had the provider up the php limit to 64M. I was getting errors with varying allocated memory sizes.
I still am getting the errors, I put in a plug-in to monitor the memory the stats below are what it shows:
* Usage Sample: 26.18MB (41%)
* Peak Usage: 26.92MB (42%)
* All-Time: 30.85MB on 3/25/10 @ 3:59 am (shutdown)
* Load Averages: 0.54 0.55 0.54
* WP Memory Limit: 64M
* PHP Memory Limit: 64M
most of the recent errors have an allocated memory of 20971520 which I believe is 20M, yet I cannot find where that setting is, and as shown below it occurs in different plug-ins.
I am stumped.
maybe I will disable various plug-ins until it stops.
Fatal error: Out of memory (allocated 20971520) (tried to allocate 122880 bytes) in /home/weaver/public_html/wordblog/wp-includes/pluggable.php on line 342
Fatal error: Out of memory (allocated 20971520) (tried to allocate 24577 bytes) in /home/weaver/public_html/wordblog/wp-settings.php on line 601
I’ve tried 4th option: define(‘WP_MEMORY_LIMIT’, ’32M’);
But I used ’64M’ instead of ’32M’ because my default settings was set to ’40M’. I’ve been trying to bring the error out by clicking to and from the home page but I don’t see the error anymore. Thank God for blessing Raju with a means and a will to help others.
My site is moving faster, which nice side-effect
nice article,
i am trying to upload 4 MB image but it gives me fatal error : Out of Memory. although i have 40 MB set in phpini
is there any more setting required.