How to solve Fatal error: Allowed memory size exhausted in PHP

How to solve Fatal error: Allowed memory size exhausted in PHP

All of a sudden one day i found that one of my Blogs crashed while installing a plugin  saying “Allowed memory size exhausted”

I quickly searched on Google and found that this error is caused by insufficient memory allocation in php.ini file. A standard server (linux box) setup comes with 8M memory and we need to increase this to avoid these types of errors.


Fatal error: Allowed memory size of 8388608 bytes exhausted (tried to allocate 8192 bytes) in/home/

So i contacted my hosting company and they informed me that since i am on a shared hosting i had a limit on the amount of memory i can use. Initially i was a lil sad, but the limit was not bad !! the one i was using and crashing was 8 MB while the limit i could use was a comfortable 40 MB , for some host its 24 and some its commonly 32MB.

For those of you who use shared hosting the quick solution would be to add a line in .htaccess file located at your root folder OR creating a php.ini file in your root

Add a line in .htaccess file located at your root folder  php_value memory_limit 24M here 24M is an example and most of the times this is enough to get your site back, contact your host support if this doesn’t work.

First step for this is to locate your php.ini file in the server and to see what is the memory limit (this is shown in the error message). Create a file with the below code and name it something like “test.php”
view sourceprint?
1.<?php phpinfo(); ?>

Upload this file to your site root and point your browser to this file, now it will show the phpinfo of the server, in this you will find “Configuration File (php.ini) Path: /usr/local/lib/php.ini”, this is your php.ini location. You can find the memory limit also in this page “memory_limit: 8M”


create a php.ini file in the root folder and add a line in it : memory_limit=40

Now your site should be up, let me know if this helped, i dont spending more time helping you guys, so feel free to add questions