WordPress is awesome to build any website easily as there are lots of plugins available to which are helpful to implement any functions you may need. These plugins are running on your site as a seperate software or extensions. By default, the WordPress has a memory limit of 40MB. This is not enough to run some large and complex plugins like WooCommerce and others. The necessity of increasing this WP_MEMORY_LIMIT comes to front when you get the following error.
Fatal error: Allowed memory size of 23556632 bytes exhausted (tried to allocate 3349917 bytes) in /home/xxxxx/public_html/wp-includes/plugin.php on line xxx
Steps to increase memory allocating to PHP in WordPress
WP_MEMORY_LIMIT option specifies the maximum amount of memory PHP can consume while running background processes in WordPress. Allocating more memories is not only helpful to run large plugins, but it has positive impacts in overall website performances as well.
To increase the default WordPress allowed memory limit for your website:
- Go to the root directory where the WordPress is installed and open the wp-config.php file.
- Search for the following line that you can find near the end of the file.
/* That's all, stop editing! Happy blogging. */
- Add this following line just above that line.
- Save your changes and re-check if the fatals error exists.
Steps above will lead you to increase your website’s WP_MEMORY_LIMIT to 64MB. However, if you need to set a higher memory limit, increase the value only.
define( 'WP_MEMORY_LIMIT', '96M' );
define( 'WP_MEMORY_LIMIT', '128M' );
define( 'WP_MEMORY_LIMIT', '256M' );
define( 'WP_MEMORY_LIMIT', '512M' );
If you are still getting any fatal errors, please consider contacting your web hosting provider or server administrator. Hopefully, they can help.