WP memory limit is the maximum amount of memory (RAM) that a website can use at one time. Once the allocated memory limit is exhausted, your website will start to encounter a fatal error. Some of the factors that contribute to the exhaustion of the WP memory limit include; WordPress itself, the theme being used and also the list of active plugins. The more complex and bigger your website is, the more memory it needs. The default memory limit for WordPress is 32MB.
32MB memory limit may be ideal for small websites with limited number of plugins and visitors. Installing a fully functional demo of a premium theme that require a large list of custom plugins to be installed too, may require you to increase the WP memory limit. Generally, it’s advisable that once you start encountering the ‘Fatal Error: Memory Size Exhausted’ error, you should increase your website’s WP memory limit.
How to increase WP memory limit
The recommended WordPress memory limit is 256MB.
a. wp-config.php
- Locate the wp-config.php file in the root directory of your WordPress installation. Using cPanel or FTP/SFTP, go to File Manager > public_html.
- Locate the wp-config.php file under the public_html folder, right click on it and select the ‘Edit’ option.
- Locate the line that has; define( ‘WP_MEMORY_LIMIT’, ’32M’ );
- Change the memory limit from 32M to 256M.
- Save the wp-config.php file then refresh your website.
b. php.ini
- Locate the php.ini file. If you can not find it, then simply create your own php.ini file and place it in the root directory of your WordPress installation. Using cPanel or FTP/SFTP, go to File Manager > public_html.
- Locate the .php.ini file under the public_html folder, right click on it and select the “Edit” option.
- Locate the line that has; memory_limit = 32M. If you created your own php.ini file, ensure you add the line.
- Change the memory limit from 32M to 256M.
- Save the php.ini file then refresh your website.
Some shared hosting providers restrict you from accessing the php.ini file. This method is only applicable in case you have direct access to your php.ini file or if you are running your WordPress on a local host. It is good to note as well that this method only affects your PHP memory limit.
c. .htaccess
- Locate the .htaccess file in the root directory of your WordPress installation. If you can’t find it then it might be hidden. Make sure to check your hidden files when locating it. Using cPanel or FTP/SFTP, go to File Manager > public_html.
- Locate the .htaccess file under the public_html folder, right click on it and select the “Edit” option.
- Locate the line that has; php_value memory_limit 32M. If you can’t find that line, you can simply add it before the # END WordPress line.
- Change the memory limit from 32M to 256M.
- Save the .htaccess file then refresh your website.