bookmark_borderIncreasing Your PHP Memory Limits

Sometimes, you may come across issues such as errors when exporting a large number of entries, or even errors stating that your available memory has been exhausted. These errors are caused by PHP limits within the server and/or the WordPress installation being too low for the amount of data being processed.

In this article, we will show you how to fix errors related to your PHP memory limits.

Note: In most cases, you will need to modify the PHP memory limit within WordPress, as well as your server’s PHP memory limit. Increasing only one of these may cause your issue to persist due to the limit in the other.

Modifying WordPress’ memory limit

Note: Even after increasing your memory limit inside this file, you will still also need to increase it on the server side, usually in your php.ini file. If either of these is too low, you will still experience issues.

To modify the memory limit used by WordPress, place the following in your wp-config.php file. This file is located at the home directory of your WordPress installation.

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

Of course, you can change this to anything you want to. In the above example, we have simply set PHP scripts to be able to use 4GB on memory which is far more than should be required.

Modifying your server’s memory limit

As stated in the previous section, you will need to change both the WordPress memory limit and the server memory limit. In addition to the steps in this section, be sure to follow the instructions in the above section to increase the memory limit available to WordPress.

Note: You do not need to (or may not even be able to) complete all of the below items. One of them is enough.

Modifying your memory limit in php.ini

If you have a php.ini file within your site’s home directory, locate the line containing memory_limit and edit it to the following:

memory_limit = 4086M

Modifying your memory limit in .htaccess

If you don’t have a php.ini file available, you may be able to modify your memory limit from within your .htaccess file. This file is located within the home directory of your site. If you don’t see if, be sure that hidden files are visible.

Place the following in the top of your .htaccess file:

php_value memory_limit 4086M

Follow your web host’s instructions

As we cannot entirely predict every variable within your web host’s configuration, these are generic, common settings and you may need to take further steps if the above settings do not work. A few popular hosts’ steps on changing your php memory limit can be found at the following:

InMotion Hosting
Bluehost
Hostgator
SiteGround
GoDaddy