In this article, we'll dive into how to increase your WordPress memory limit to make sure your site runs smoothly.
Prerequisites for Increasing WordPress Memory Limits
Before you start, you need to make sure that the following conditions are in place:
- Permissions to access .htaccess files: Usually in the WordPress root directory, you can use theFile manager or FTP clientFind.
- Access to the wp-config.php file: This is the core WordPress configuration file, located in the WordPress root directory.
- Maximum memory limit for hosting settings: Make sure the hosting provider's maximum memory limit is high enough so that you are not constrained when you tweak it.
Frequently Asked Questions about Insufficient Memory Limit
When WordPress runs out of memory, you may encounter the following issues:
- Error code 500: This is a common internal server error, often caused by insufficient memory.
- fatal error: similar to
Fatal error: Allowed memory size of XXXX bytes exhausted
maybeFatal error: Out of memory
of the error message.
How to detect errors caused by insufficient memory limit
To confirm whether insufficient memory is the source of the problem, follow the steps below:
- Open File Manager: Use a hosting panel (e.g. Pagoda, cPanel, Plesk) or an FTP client to access site files.
- Finding the error_log file: This file records error messages for the site, usually
public_html
maybewww
Folder.
- Check the update time of the error_log file: Make sure the error log is recent.
- Open the error_log file: Look for the last few lines if you see
Fatal error: Allowed memory size
and other information indicating that the site is indeed experiencing problems due to lack of memory.
Increase WordPress Memory Limit with .htaccess
If you have access to the .htaccess file, you can follow the steps below:
- Open File Manager: Access the file manager through the hosting panel or the WordPress plugin.
- Finding .htaccess files: If the file is not visible, enable the "Show hidden files" option.
- Editing .htaccess files: at the end of the document
# END WordPress
Add the following code under:php_value memory_limit 256M
commander-in-chief (military)256M
Modify to the desired memory size (e.g. 512M).
- Save Changes: Save the file when finished.
- clear the cache: If a cache plugin is used, it is recommended that the cache be cleared first to ensure that the changes take effect.
Increase WordPress memory limit with wp-config.php
If you cannot access the .htaccess file, you can also use the wp-config.php file to adjust the memory limit:
- Accessing the wp-config.php file: Locate the file through a file manager or FTP client.
- Edit the wp-config.php file: in the file
/* That's all, stop editing! Happy publishing. */
Add the following code above the code line:define( 'WP_MEMORY_LIMIT', '256M' );
It is possible to combine256M
Modify the memory size to fit your needs. - Save Changes: Save the file when finished.
- clear the cache: It is also recommended to clear the cache to ensure that the changes take effect.
Adjusting Memory Limits with the PHP Settings Panel
If your hosting panel provides a PHP Settings panel, you can adjust the memory limits directly from this panel without modifying the files. Here are the steps to do so:
- Open the hosting panel: Log in to Pagoda, cPanel, Plesk, or other hosted panels.
- Find PHP Settings: Usually located in the "PHP Settings" or "PHP Configuration" option of the panel.
- Select PHP INI Settings: In PHP Settings, find "PHP INI Settings" or similar.
- Adjusting memory limits: Next to the "Memory Limit" or similar setting, set the memory value to the size you need, e.g.
256M
maybe512M
The - Save settings and apply: Click the "Update" or "Save" button to make sure the changes take effect.
- clear the cache: It is recommended that the cache be cleared to ensure that the new memory limit settings are applied.
Troubleshooting Memory Issues with Plugins
If you can't access .htaccess or wp-config.php files through your control panel, you can also consider using the WordPress File Manager plugin. Once installed, you can manage files and adjust settings directly in the WordPress backend.
summarize
Increasing the memory limit of WordPress is one of the most important steps to ensure that your website runs smoothly. Adjustments to the .htaccess and wp-config.php files can easily increase the memory limit and prevent problems caused by insufficient memory.