If you have a WordPress site, it’s important that you have enough memory allocated to run the software smoothly. Depending on your site’s size and complexity, you may need to increase it. However, before you do, you’ll need to determine your current memory limit.
In this article, we’ll show you how to check your current WordPress memory limit and how to increase it if necessary, as well as answer some of the most frequently asked questions about WordPress memory limits.
What is the PHP memory limit in WordPress?
The PHP memory limit is the maximum amount of memory that a PHP script can use. If a WordPress site exceeds its PHP memory limit, it will likely experience errors. These errors can include the “white screen of death,” slow page loading, and database connection issues.
Often, the error will appear as follows:
“Fatal error: Allowed memory size of XXXXXXX bytes exhausted (tried to allocate YYYYYYY bytes) in /path/to/file.php on line ZZZ.”
You’ll come across this error when trying to install WordPress plugins or themes, run updates, or perform some other action on your site.
How to check your WordPress memory limit
There are a few ways to check your WordPress memory limit:
- Check your WordPress hosting account.
- Check your wp-config.php file.
- Ask your WordPress host.
- Use WordPress Site Health.
- Use a WordPress plugin.
Let’s review each of these options in more detail.
1. Check your WordPress hosting account
The first place to check your WordPress memory limit is in your hosting account. Many hosts will list the current PHP memory limit in the account control panel. In cPanel, this is located under the Software section. Click PHP Selector, then navigate to the document root of the directory you’d like to work with. You’ll likely see information as follows and this will tell you which PHP version your site is currently using:
Then, go to Options and scroll down until you see the line that reads memory_limit. Your site’s current settings should be visible here.
2. Check your wp-config.php file
The second place you can check your WordPress memory limit is in the wp-config.php file. This file is located in the root directory of your WordPress site. To access it, you’ll need to connect to your site using an FTP client like Filezilla or through the File Manager in cPanel. Once you’re connected, open the wp-config.php file in a text editor like Notepad++.
Next, search for the following line of code:
This line of code defines the maximum amount of memory that can be used by WordPress. The number following WP_MEMORY_LIMIT represents the maximum memory limit in megabytes. In this example, it’s set to 256MB.
If this line is not present in your wp-config.php file, you can add it to the end of the file. Be sure to save your changes before exiting.
3. Ask your WordPress host
If you’re not sure where to find your WordPress memory limit or you’re unable to access your hosting account or wp-config.php file, you can always contact your WordPress host and ask them what the current PHP memory limit is for your site. To do this, you’ll typically need to open a support ticket with your host or send them an email.
4. Use WordPress Site Health
If you want an easy way to check your WordPress memory limit (and other site details), you can use the WordPress built-in Site Health tool, which gives you an overview of your site’s health, including the current PHP memory limit.
This module will show you the current memory limit for your WordPress site. To access it, go to Tools → Site Health in your WordPress dashboard and click on the Info tab. Expand Media Handling and, under Server, look for the PHP memory limit.
5. Use a plugin
Another option is to use a plugin to get access to this information. Here are two that are up for the task:
- WP Healthcheck: This plugin gives you an overview of your WordPress site’s health, including the current memory limit. Plus, it helps improve your site performance by removing transients and other unnecessary data.
- Health Check & Troubleshooting: In addition to presenting your memory limit and other server information in an easy-to-consume way, this tool identifies configuration and setup issues. This can be extremely helpful if you’re working with a support team to troubleshoot a problem.
How to increase the WordPress memory limit
If you need to increase your WordPress memory limit, here’s the optimal process to follow:
- Back up your site before editing any code
- Edit wp_memory_limit in your wp-config.php file
In some cases, you may also need to take the following additional steps:
- Edit memory_limit in your PHP.ini file
- Edit your .htaccess file
- Contact your hosting provider
Let’s review each of these in more detail.
1. Back up your site before editing any code
Before you make any changes to your WordPress site, it’s important to back up your data first. This will ensure that you have a copy of your site that you can revert back to if something goes wrong. There are a few different ways to back up your WordPress site:
- Use a WordPress backup plugin like Jetpack Backup
- Manually export your WordPress database
- Use a staging environment
- Use server snapshots (if available)
- Ask your WordPress host if they offer backups
Jetpack provides the simplest method of backing up your WordPress site. You can download a copy in just a few clicks without having to deal with accessing your server. And if something goes wrong while increasing your memory limit, you can restore that backup even if your website is completely down. The best part? In the future, you’ll be protected with automated, real-time backups that save your site every single time a change occurs.
Learn more about how to back up your WordPress site with Jetpack.
2. Edit wp_memory_limit in your wp-config.php file
If you want to increase your WordPress memory limit, the first place to start is with your wp-config.php file. This file is located in the root directory of your WordPress site. You can navigate here using an FTP client or through the File Manager in cPanel as previously mentioned.
To edit your wp_memory_limit, simply download the file and open it in a text editor. Then look for the line that says:
Replace the memory limit with a higher number. For example, if you wanted to increase your memory limit to 256M, you would use:
Save your changes. Upload the file back to your server. Your site’s memory limit should now be increased.
3. Edit memory_limit in your PHP.ini file
If you’re unable to edit the wp_memory_limit in your wp-config.php file, or if you want to increase the memory limit for more than just WordPress, you can edit the memory_limit setting in your PHP.ini file.
The PHP.ini file is located in the root directory of your WordPress site, but if your hosting provider uses cpanel, you can easily change the memory limit from that dashboard.
Navigate to cpanel, and find the MultiPHP INI Editor in the Software section. From the dropdown that appears, select your website. Look for “memory_limit” and change it to whatever number you’d like. Save your changes. Your memory limit should now be increased.
4. Edit your .htaccess file
If you’re still unable to increase your WordPress memory limit using the previous methods, you can try adding the following line of code to your .htaccess file:
php_value memory_limit 256M
The .htaccess file is located in the root directory of your WordPress site. If you don’t see this file, make sure that you’ve enabled hidden files in your FTP client.
You can do this by going to the Server or Connection settings in your FTP client and checking the box that says Show hidden files. You can do this in cPanel as well by going to File Manager, clicking Settings in the top right corner then checking the box that reads Show Hidden Files (dotfiles).
5. Contact your hosting provider
If you’ve tried all of the above and you’re still unable to increase your WordPress memory limit, your last resort is to contact your hosting provider. You may need to upgrade your hosting plan to accomplish this, especially if you’ve used up your resources.
Your host should be able to help you increase your memory limit and point you in the right direction if you need to upgrade your hosting plan to something more robust, like a managed WordPress hosting plan, or even a VPS or dedicated server.
Frequently asked questions
Here are some answers to common questions people have about the WordPress memory limit:
1. Why increase the WordPress memory limit?
There are a few reasons why you might need to increase your WordPress memory limit:
- Your site is loading slowly
- You’re seeing white screen of death errors
- You’re seeing “out of memory” errors
- Your hosting provider recommends it
2. What is the recommended wp_memory_limit?
The general rule of thumb is that you should have at least 64MB of memory allocated for WordPress. However, this can vary depending on the size and complexity of your site. If you’re not sure how much memory your site needs, you can start with 64MB and increase it as needed.
3. How do I know if I need to increase my WordPress memory limit?
There are a few signs that you may need to increase your WordPress memory limit:
- You see an error message saying, “Allowed memory size exhausted”
- You see an error message saying, “WordPress has encountered an error and needs to restart”
- Your site is loading slowly or timing out
- You’re seeing “white screen of death” errors
4. What happens if I don’t increase my WordPress memory limit?
If you don’t increase your WordPress memory limit, you may see errors on your site, or your site may load slowly. In some cases, it may even crash.
5. Will increasing my WordPress memory limit slow down my site?
Generally speaking, no. However, if you allocate too much memory to WordPress, it can cause your server to slow down and impact your site speed.
6. What happens if I try to allocate more memory than my server has?
If you try to allocate more memory to WordPress than your server has, you’ll see an error message saying “Fatal error: Allowed memory size of xxxxxxx bytes exhausted.” This means that you need to increase the amount of memory your server has, or reduce the amount of memory WordPress is trying to use.
7. What is the maximum WordPress memory limit?
The maximum memory limit for WordPress is 512MB. However, depending on your server and WordPress settings, you may not be able to allocate this much memory to WordPress.
8. What’s the difference between wp_memory_limit and wp_max_memory_limit?
The wp_memory_limit setting defines the maximum amount of memory that can be used by WordPress. The wp_max_memory_limit setting defines the maximum amount of memory that can be used by WordPress and any plugins or themes. If you’re having errors with a plugin or theme, you may need to increase the wp_max_memory_limit setting.
9. I’m still having problems. What should I do?
If you’ve tried all of the above and you’re still having problems, your best bet is to contact your hosting provider and ask them for help. They’ll be able to take a look at your server and WordPress settings and help you figure out what’s going on.
Increase your WordPress memory limit
Learning things like how to increase your WordPress memory limit is an exciting part of expanding your skills as a site owner. We hope you’ve found this post helpful. If you’re still seeing errors or slow performance, we recommend contacting your hosting provider for help.
Explore the benefits of Jetpack
Learn how Jetpack can help you protect, speed up, and grow your WordPress site.
Get up to 60% off your first year.Compare plans