Wednesday, July 29, 2015

The Famous Fatal Error - PHP Memory Allocation

Memory Allocation in PHP apparently is the most common error that WordPress users would have come across. PHP by its very nature consumes memory on the server. Your hosting provider would either allocate the memory or may even allow you to increase the allocation. Most hosting providers might allocate only 8MB for PHP. Normally, single installation of WordPress can make PHP consume atleast 16MB of memory. Also, there are possibilities that you are using some other PHP application or CMS on your server which is also taking away the allocated PHP memory. In all such cases where memory is not sufficient, WordPress throws an error which is usually in this format:

 "Allowed memory size of NNN bytes exhausted". 

Solution for PHP Memory Allocation

Firstly, check if you have the rights to change memory allocation. If you do not have, proceed straight to your hosting service provider to increase the PHP memory limits. If you have the rights to change memory allocation, then open wp-config.php file in a text editor and add this line:
define( 'WP_MEMORY_LIMIT', '64M' ); 
You can change 64M to the desired value. You need to add this line just above this line:
 /* That's all, stop editing! Happy blogging. */ 

By writing this piece of code, you are instructing WordPress to increase PHP Memory allocation exclusively for WordPress only. This will resolve most of the errors caused due to lower PHP memory allocation.

No comments:

Post a Comment