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.

Leave a Reply

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