Menu Close

WordPress: Fatal error : Allowed memory size exhausted


When upgrading my blog to WordPress 2.8.4, the upgrade failed with the following error:

Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 2357046 bytes) in xxx.php on line yyy



I wanted to upgrade my blog to the latest WordPress version (2.8.4). Also, I was using 10 plugins on my WordPress blog, the latest addition being GD Star Rating 1.6.4.



I upgraded GD Star Rating to version 1.6.5 and this upgrade fixed the problem, thereby permitting me to upgrade WordPress to version 2.8.4. However, after both upgrades, my blog’s dashboard displayed the fatal error in 2 locations as shown in the screenshot below:


Such fatal errors occur when a PHP script hits the threshold for the maximum amount of memory it may consume. Some WordPress forums indicate that WordPress 2.8 is more memory-intensive than earlier wordpress versions. And my hosting provider defined a memory_limit of 32MB in php.ini.


In order to override my PHP system memory_limit of 32 MB and allow the WordPress application to use more memory, I edited the wp-config.php file (in server docroot) and added the following:


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


After I modified and saved wp-config.php, the fatal errors disappeared from my WordPress Dashboard.


Some more investigation revealed how WordPress sets its memory limit in wp-settings.php via the following code:


if ( !defined('WP_MEMORY_LIMIT') )
	define('WP_MEMORY_LIMIT', '32M');
if ( function_exists('memory_get_usage') && ( (int) @ini_get('memory_limit') < abs(intval(WP_MEMORY_LIMIT)) ) )
	@ini_set('memory_limit', WP_MEMORY_LIMIT);


So, that’s why setting the WP_MEMORY_LIMIT variable in wp-config.php (you could set it in wp-settings.php also, but it’s recommended to consolidate all config in one file) increases the memory limit for the WordPress application.


Root Cause:

The PHP memory limit of 32MB was too low for the WordPress 2.8.4 application.



(1) The solution above describes a successful problem-solving experience and may not be applicable to other problems with similar symptoms.

(2) Your rating of this post will be much appreciated. Also, feel free to leave comments.

VN:F [1.9.22_1171]
Rating: +5 (from 5 votes)
Print Friendly, PDF & Email

Leave a Reply

Your email address will not be published. Required fields are marked *