Sakin Shrestha

Fix PHP Fatal error: Allowed memory size of 33554432 bytes exhausted

Updated: 11 June 2014. Published: 22 October 2009

Fix PHP Fatal Error
Fix PHP Fatal Error

I just upgraded my WordPress and then I got PHP Fatal Error problem. Also when I tried to upgrade the plugin, the error keeps on coming which prevent me from upgrading the plugins.

Example 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

To fix this PHP Fatal Error problem in WordPress, you can use following tricks.

Increasing memory allocated to PHP

Many times you will get this error due memory size allocated for PHP less then needed. Please note, this setting may not work if your host does not allow for increasing the PHP memory limit–in that event, contact your host to increase the PHP memory limit.
Increase PHP Memory using wp-config.php file
Use your FTP access or hosting access and then find wp-config.php file in your WordPress installation root directory and then add the following code in your wp-config.php file. If 64M doesn’t work then you can further increase to 96M or more.

define( 'WP_MEMORY_LIMIT', '64M' );

Increase PHP Memory using php.ini file
Use your FTP access or hosting access and then find php.ini file and then edit the memory_limit. If 64M doesn’t work then you can further increase to 96M or more.

memory_limit = 64M;

Increase PHP Memory using .htaccess file
Use your FTP access or hosting access and then find .htaccess file in your WordPress installation root directory and the add the following code. If 64M doesn’t work then you can further increase to 96M or more.

php_value memory_limit 64M

If the above option doesn’t work then try the following steps

Step 1: Open the file wp-includes/cache.php and add the following code immediately after the opening <?php

ini_set( 'memory_limit', '64M' ); // set memory to prevent fatal errors

Step 2: create an htaccess file for the wp-includes directory and add the following code:

# set memory limit for cache.php
php_value memory_limit 64M

Step 3: Create php.ini file, add the following code and upload in the same directory (wp-includes):

;; set memory limit for cache.php
memory_limit = 64M

If necessary, you may try increasing the values for the memory limit.

If you have problem with editing these files then you can download the complete set I have customized for my site.
Click here to download.

Exit mobile version