Allowed Memory Size Of xxxxxx Bytes Exhausted on WordPress Page

Recently, we got a message like “Allowed memory size of xxxxxxxx bytes exhausted” on Internet Techies sitemap page (where xxxxxxxx was some big number, oops I don’t remember!!) . We found out that this error was due to the fact that our PHP code generated for that page was crossing the allocated memory limit on the server.

This error can be overcome by using the WP_MEMORY_LIMIT option in wp-config.php file. You can get your wordpress installation’s wp-config.php file in your installation’s root folder.

Open wp-config.php file in any text editor you use to edit html or php, and go to the end of the file.

wp_config_endBefore the above highlighted line, put this code

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

The value 64M in the above code is the memory limit that WordPress has allocated to PHP. By default, WordPress keeps the memory limit to 32M. But if the PHP code for a certain page needs more memory than the default, then, we have to increase the memory limit by using the WP_MEMORY_LIMIT option in wp-config.php

Save the modified wp-config.php file to the WordPress installation’s root folder. And now try to open the page showing the error, if the error has gone, well good! If not, then try increasing the memory limit to 96M and so on.

64M worked for us!

Important Notes:-

  1. This setting may not work if your web host does not allow the PHP memory limit increase on the server. In that case you need to contact your host to increase the PHP memory limit. Also, note that many hosts set the PHP limit at 8MB. If you wish to get a good PHP memory limit extending options you could try Hostmonster, we have a very good experience with this web hosting service provider. Also you can go thru some of the best web hosting accounts for your website or blog
  2. Also, remember that by increasing this memory limit, you are allocating more memory for the PHP pages on this instance of WordPress installation, and not other pages on your web site or server that are outside of this concerned WordPress installation instance.
  3. This option has been introduced with wordpress version 2.5. So, if you have your WordPress installation prior to version 2.5, then you need to contact your web hosting service directly to get the PHP memory allocation increased.
  • We had a similar issue when we did our last automatic WordPress upgrade. We got a similar error and we had to go in and modify our memory limit. Once modified, the new version loaded like a a champ!

  • Great tip and fix. Thank you very much for posting this. I was having issues with this when I upgraded to the newest version of WordPress. This fix corrected the issue immediately.

    Again, kudos. Thank you very much for posting this.

  • @Samuel I am glad that the fix solved your problem, this type of tips and fixes are part of “Internet Techies”. You did a great job for your blog by upgrading it to latest version as there are some security threat to previous versions. Wish you all the best for your updated blog.

  • Wow, awesome fix. I ran into this in a 2.9 to 2.9.1 upgrade. Thank you so much!

  • Thank you very much! This realy helped me!

  • After I tryed this, I got another error. I solved it already but it drove me crazy.