How to increase memory limit in WordPress?

Error message

Fatal error: Allowed memory size of 12345678 bytes exhausted (tried to allocate 2345678 bytes) in /home/your-username/public_html/wp-includes/plugin.php on line 1000

This error message informs you about the memory limit and tells you how many bytes it was exceeded. There is also a filepath to a file that caused the error and a specific number of a line inside that file. If none of the below methods won't work, then this info can be useful when reporting the error to the plugin developer.

Another version of that error message:

Fatal error: Out of memory (allocated 12345678) (tried to allocate 2345678bytes) in /home/your-username/public_html/wp-includes/plugin.php on line 1000

Both messages tell you that there is no memory left for PHP scripts. It is caused by the server's limit and in most cases changing the server's configuration will solve this issue. However, sometimes the server's configuration cannot be changed or the allowed memory limit is very low.

Increase the WordPress memory limit

By default, WordPress will attempt to increase the memory allocated to PHP to 40MB for a single site and 64MB for multisite. If you experience an error showed above, it means that these values are too low. What is the required memory limit? It depends on the plugins you are using. 128 MB is usually enough, but for some plugins, it may be too low.

You can check your memory limit in the WooCommerce System Status (in your WordPress admin panel: WooCommerce > Status)

In some cases, the value displayed in the System Status might not be correct. If the server has a higher limit than the one set for WordPress, then in the Status there will be shown a maximum value for WordPress. The value can also be incorrect if the limit set in wp-config.php is higher than the one in the server settings.

Edit php.ini file

You need access to the php.ini file. Change this line. If your line shows 64M try 128M:

memory_limit = 128M

M stands for Megabytes.

Edit .htaccess file

If you don’t have access to php.ini or the above method had failed, please try adding this to a .htaccess file:

php_value memory_limit 128M

.htaccess file is located in the root directory of your WordPress installation.

Edit wp-config.php file

Add this to the top of the file, before the line that says, “Happy Blogging”:

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

The wp-config.php file is located in the root directory of your WordPress installation.

Change your PHP version

It may happen that the solutions listed above will fail.

Hosting providers sometimes do not allow to edit the memory limit or the limit is too low. In this case, you should contact your provider and ask him to set a higher memory limit. If the limit won't be high enough, you should change your hosting plan or choose a different hosting provider.

There is also another way of solving this issue. You can change your PHP version to a higher version. New PHP versions are more efficient and often use less memory. If you have such a possibility, change your PHP version to 7.2 or higher one.

Still need help? Contact Us Contact Us