How to Increase WordPress Memory Limit
The WordPress memory limit determines how much memory PHP scripts can use while executing tasks on your website. If you encounter errors like “Allowed memory size of X bytes exhausted,” it means your site has hit the memory limit set on your server.
This tutorial will guide you through various methods to increase the WordPress memory limit.
Why Increase the WordPress Memory Limit?
WordPress tasks like importing large files, running resource-heavy plugins, or processing complex tasks can require more memory. By increasing the memory limit, you prevent errors and ensure smoother performance.
How to Check Your Current WordPress Memory Limit
To check your current memory limit:
- Log in to your WordPress admin dashboard.
- Go to Tools > Site Health > Info.
- Expand the Server section to see the memory limit value.
Methods to Increase WordPress Memory Limit
1. Edit wp-config.php
The wp-config.php file is the main WordPress configuration file.
Steps:
- Access your WordPress files via FTP or your hosting control panel (e.g., cPanel).
- Locate the
wp-config.phpfile in the root directory of your WordPress installation. - Open the file in a text editor.
- Add the following line before the line that says
/* That's all, stop editing! */:
define( 'WP_MEMORY_LIMIT', '768M' );
- Save and reupload the file to your server.
This sets the memory limit to 768MB, which is optimal for most WordPress websites.
2. Edit php.ini File
The php.ini file configures PHP settings on your server.
Steps:
- Access your website’s files via FTP or your hosting control panel.
- Locate or create a
php.inifile in the root directory of your WordPress installation. - Add or update the following line:
memory_limit = 768M
- Save and upload the file to your server.
3. Modify .htaccess File
The .htaccess file is a configuration file used by your web server.
Steps:
- Access your WordPress files via FTP or your hosting control panel.
- Locate the
.htaccessfile in the root directory. - Back up the file before editing it.
- Add this line to the end of the file:
php_value memory_limit 768M
- Save and reupload the file.
4. Use cPanel to Increase PHP Memory Limit
If your hosting provider uses cPanel, you can change the memory limit directly.
Steps:
- Log in to your cPanel account.
- Go to Select PHP Version or MultiPHP INI Editor (names may vary by host).
- Look for the
memory_limitsetting. - Increase the value to 768M.
- Save changes.
5. Install a WordPress Plugin
If you’re not comfortable editing files manually, you can use a plugin like WP Config File Editor to increase the memory limit.
Steps:
- Log in to your WordPress dashboard.
- Go to Plugins > Add New and search for “WP Config File Editor.”
- Install and activate the plugin.
- Use the plugin’s interface to modify the memory limit value.
6. Contact Your Hosting Provider
If none of the above methods work, it’s likely that your hosting provider has restricted the memory limit. Contact their support team and request an increase to 768MB or higher if necessary.
Best Practices
- Avoid excessive memory allocation: While 768MB is suitable for most WordPress sites, setting it unnecessarily high can impact server performance.
- Monitor resource usage: If memory issues persist, check for inefficient plugins or themes consuming resources.
Conclusion
Increasing the WordPress memory limit to 768MB ensures smooth performance for resource-heavy tasks and avoids memory errors. You can achieve this by editing the wp-config.php, php.ini, or .htaccess files, or through cPanel.
Need expert help? Contact the professionals at WPsite.com for seamless WordPress support! 🚀