Fix the PHP Fatal Memory Error for WordPress
Anytime Automattic, the creators of WordPress, release the latest version of their very popular Content Management System (CMS) it is bound to have unforeseen issues that cause the system to break temporarily. In this case when clicking the automatic upgrade button for either the newest version of WordPress, installing or upgrading new plugins, or adding/editing posts or pages causes WordPress to give a PHP Fatal Error message. WordPress runs on PHP. It means though the error you are getting is on your WordPress Blog. But, it is related to a PHP Error.
The reason is simple. Your WordPress blog is overloading your PHP with lots of instructions and thereby exhausting the memory.
Therefore, This is an memory issue. It can be solved easily by changing some WordPress Core files.
Examples of the Error:
PHP Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 6233929 bytes) in /public_html/…/wp-includes/cache.php on line 330
“WordPress Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 16842 bytes) in wp-db.php on line 501″
Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 907869 bytes) in /public_html/wp-includes/http.php on line 1327
Below, is the best possible solution to resolve the issue. You will be changing two files php.ini and wp-settings.php
Before you change modify files mentioned below, Please make a back up of it!
Login in your into your control panel and click File Manager.
You should have a php.ini file in the cgi-bin folder one level below the root of your domain folder. If you don’t you should create one.
Open php.ini in the file editor and look for “memory_limit” (without quotes)
1 memory_limit = 32M ; Maximum amount of memory a script may consume (32MB)
You should find a line similar to the one above.
Try to increase the Number by multiplying by 2. For ex: if your php.ini shows 16M then try changing 32M. In our case, we change it to 64M.Here we are telling PHP to use 64M of memory instead of 32M.
Save the file and close the editor.
Now move to your WordPress directory and look for wp-settings.php file and open in File Editor
Look for the following two lines:
1 if ( !defined('WP_MEMORY_LIMIT') )
2 define('WP_MEMORY_LIMIT', '32M');
Once you find it, try changing it to the number that you have changed in php.ini in the above steps. In our case we changed the second line to 64M Here we are trying to increase the Memory usage of WordPress by telling WordPress to use 64M instead of 32M by modifing it in wp-settings.phpRemember :
You will need to make the above change to wp-settings.php after you upgrade the WordPress. As these changes will be overwritten by new file.
Save the file and close the editor.
Now, you are done. Try loading WordPress Dashboard page or any WordPress page where you were getting “WordPress Fatal error: Allowed memory size” error. Most likely, you won’t see it.




