Overview
Your plugins aren’t functioning properly. Your website isn’t loading properly. The error “Allowed memory size exhausted” continues appearing, and it keeps telling you to increase your PHP memory limit. What exactly is it, and how do you deal with it?
The PHP memory limit was created to prevent RAM-hungry resources from crashing your website. However, it can sometimes cause issues, such as when you install a plugin that requires a bit more power and it ends up blocking access to your site.
If you’re experiencing the white screen of death owing to a lack of memory, you should seek immediate assistance. Let’s look at the PHP memory limit and how to deal with it if you reach the resource limit.
Contents Table of Contents
What Is PHP Memory Limit?
In WordPress, how can I increase the PHP memory limit?
How Much Memory Should PHP Have?
Plugins aren’t functioning properly. Your website isn’t loading properly. You’re aware that your PHP memory limit needs to be increased… but how do you go about doing so? Click here to learn everything you need to know about resolving this vexing problem.
TO TWEET, CLICK HERE
The PHP Memory Limit is a term that refers to the amount of memory that a PHP program
The PHP memory limit determines how much memory your website’s scripts can use. But, exactly, what does that imply?
Your website is run by servers, which are specialized machines that keep a website’s backend working. Processors, storage, and RAM — sometimes called as memory — are all used in them, just as they are in regular computers.
One of the most crucial components of a server is RAM. Each program and application uses a little amount of RAM. The more memory required by a program, the more intensive it is. Your site will become sluggish or possibly refuse to load if you run out of memory.
Web applications, such as WordPress plugins, are only one example of how your server’s RAM might be used. These programs typically take up very little space, and you’ll never have any problems unless your host has provided you with very little memory to deal with.
However, any PHP application’s script can only use a certain amount of memory on your server. When one of these scripts reaches its limit, you’ll run into issues.
You’ll get a white screen with an error message, and your entire site may be blocked.
What Is the Purpose of the Memory Limit?
Consider what would happen if something went wrong with your server. Perhaps an application becomes stuck in an unending loop, consuming ever-increasing amounts of memory, or perhaps an attacker dupes you into installing something that executes a harmful script, consuming all of your resources.
When PHP processes become out of control, the memory limit serves to put a stop to them before they crash your server or consume all of your monthly resources.
The majority of valid PHP scripts are quite small. Unless you have an odd software that requires more resources in one script than most programs will ever require as a whole, each script should only take up a small amount of RAM. These kinds of plugins do exist, although they’re uncommon.
If you run out of memory, there’s a good possibility your PHP software is defective or malicious, resulting in the memory limit error.
However, there are situations when you are utilizing a huge plugin that requires additional memory. Some web servers set the PHP memory limit very low, which can result in the issue even if you’re not installing a particularly resource-intensive application.
In either case, you’ll soon run into the memory exhausted error.
The Error of Memory Exhaustion
So you’ve run into the memory exhaustion issue. You’re probably seeing a white screen with an error message, either throughout your website or when performing certain tasks like submitting a form.
Error: WordPress Memory Limit Has Been Exceeded
As seen in WordPress, the memory limit has been reached.
This is a significant issue, especially if it affects your entire website. Every hour that passes, a large number of visitors are lost.
A big or misconfigured plugin is most likely to blame. WordPress plugins are subject to the PHP memory restriction because they are written in PHP.
Disabling your plugins one by one until you recover access to your site will help you locate the plugin that’s causing the issue. Once you’ve found it, look through the documentation to see whether it specifies how much memory it requires to function.
If there’s no indication that it’s supposed to be a particularly powerful plugin, you should file a bug report with the plugin creator. Remember that the PHP memory restriction only applies to individual scripts, not the entire plugin. As a result, there’s a significant probability a script became trapped in an infinite loop or had some other issue.
It’s also possible that you’re the source of the problem. Maybe your RAM limit is set too low, allowing only the tiniest of plugins to function properly. Perhaps you’re attempting to install a plugin that necessitates a greater limit than usual.
You should try to increase the PHP memory limit in any situation. Let’s have a look at how to achieve that right now.
How to Increase PHP Memory Limit in WordPress
Before you do anything, you may quickly determine your PHP memory limit without having to search through any files. Go to Tools > Site Health in your backend if you’re using WordPress 5.2 or later.
If you don’t see the Health Check & Troubleshooting plugin, install it.
WordPress site security
Using WordPress to view site health information
Your PHP memory limit can be seen under the Info tab. If it’s already set to a high value, one of your plugins may be malfunctioning.
If it’s too low, you’ll need to adjust it in the wp-config.php file.
This does not always solve the issue. Your site server determines the PHP memory limit in the end. Your site may be set to use fewer resources than your server allows, which can be fixed by changing your files. However, if their hard-coded limit is too low, no matter how high you manually set the number, you won’t be able to increase it.
But because it’s worth a shot, let’s go ahead and modify that file right now.
What is the PHP memory limit for Kinsta?
The default PHP memory limit for all Kinsta plans is 256 MB. This should be more than enough for 99 percent of WordPress plugins, and in fact, it is far more than most plugins will ever need.
You should never get a RAM limit issue if you’re using Kinsta hosting and your site is configured appropriately. The maximum limit is normally established automatically in the files, so you don’t have to do anything.
Do you want to discover how we grew our traffic by over 1000%?
Join the 20,000+ people who receive our weekly email with WordPress insider secrets!
Now is the time to subscribe.
It’s still worth checking to see if it hasn’t been set mistakenly too low under WordPress settings. It’s likely that something has changed the number and reduced the amount of resources available to you.
If you continue to have problems, you can always contact Kinsta support and ask for assistance. We can assist you in locating a misconfigured file that you may have overlooked.
How to Use FTP to Change PHP Memory Limit
You’ll need FTP or SFTP access to make changes to the wp-config.php file. This enables you to make changes to critical internal files that influence the way your site works.
It should be simple because you’ll only be modifying one line. Begin by downloading and installing FileZilla or another FTP client. There’s no need to be concerned because it’s completely free. Before you begin, make a backup of your website. While editing core files, it’s simple to break something by accident.
Start FileZilla and log in using your credentials. You should be able to connect to your site after a few moments.
Find wp-config.php in the public folder. If you can’t find public or public-html, it could be root, www, or your website’s name.
wp config FileZilla
In FileZilla, look for wp-config.
Open the wp-config file. Make sure you don’t change anything except the PHP memory limit line, as this is a sensitive file that could cause your website to malfunction. Look through it till you come across the following line: define(‘WP MEMORY LIMIT’, ‘256M’); define(‘WP MEMORY LIMIT’, ‘256M’); define(‘WP ME
WordPress memory limit
WP memory limit as shown in wp-config.php
Replace the number there, save the file, and exit FileZilla. It’s finished!
In cPanel, how do I change the PHP memory limit?
Some web servers will not allow you to edit files via FTP. Instead, they might grant you cPanel access. If that’s the case, don’t worry; you can change your PHP memory limit in the same way.
Info
We don’t use cPanel at Kinsta. Instead, our clients have access to MyKinsta, a custom-built dashboard developed particularly for WordPress sites.
First, use the credentials provided by your host to log into cPanel. A Software section with a Select PHP Version button may be seen on the main screen.
Do you have troubles with downtime with WordPress? Kinsta is a hosting solution that prioritizes performance and security. Take a look at our plans.
php version of cpanel
In cPanel, choose a PHP version.
When you click it, you’ll see Switch to PHP choices at the top of the screen. Scroll to the bottom of the page until you see memory limit, which has a dropdown option. Change it to the desired setting by clicking it. You’re done when you click Apply.
A Select PHP Version option will not be available to everyone. You might instead come upon MultiPHP Ini Editor. If that’s the case, you’ll need to take some alternative measures.
cPanel’s MultiPHP Ini Editor
You’ll need to click that, then open the menu and select your domain under Configure PHP INI basic settings in the next box. Locate the memory limit section and enter the desired value. To save your changes, click Apply.
You could also use the File Manager in cPanel. This is very similar to using FTP to access your website. Click File Manager from your home page’s Files section. Open up wp-config.php in your public/public-html folder (or whatever it’s called).
Change the number in the WP MEMORY LIMIT line (as mentioned in the previous section) to anything you desire. That’s all there is to it. Save your changes and make sure they’re applied.
What Should PHP Memory Limit Be?
Your first instinct when changing your memory limit might be to set it to 900 MB or something like – as high as you can. However, this can be a really bad notion.
If one of your site’s scripts fails, it might swiftly spin out of control, crashing your entire server. Even if your site is hosted on high-performance hardware, a single script that consumes all of the RAM could pose major problems.
Misconfigured scripts that are highly taxing but not problematic could also go unreported. The memory limit issue is a warning indicator that something is wrong in the backend, because most PHP scripts are extremely short. If you set it too high, you could end up with messed-up scripts that slow down your site without you realizing it.
Setting your PHP memory limit as low as possible while still allowing your site to run normally is a good idea.
A suitable starting point is 128 MB. That’s enough memory to handle even the most resource-intensive plugins. If you know you’ll need more memory, 256 MB will plenty for even the most demanding plugins. And 512 MB is the absolute maximum you should set it to if you’re sure you’ve got a real powerhouse. You should never need to increase the RAM limit beyond 256 MB in 90% of circumstances.
What Happens If Increasing the Memory Limit Doesn’t Help?
If the memory error persists after modifying your PHP file, one of two issues exists: your host has allotted insufficient resources, or a PHP script on your server is consuming much too much memory.
Again, you should disable your plugins until you find the source of the problem. With 128-256 MB of RAM, no plugin should take up so much space without being mentioned in the description. Disable it and inform the plugin’s authors of the situation.
Even after disabling all plugins, you’re still seeing the error. The problem must be caused by a conflict or another PHP program. This is more than you can do on your own, so seek assistance from your web host.
If the problem isn’t caused by a plugin, it’s most likely because your host set the memory limit too low. You’re probably using shared hosting, which is renowned for assigning extremely little memory – rightfully so, because if a site uses too much RAM, it slows down the entire system for dozens of other websites.
You have no choice but to upgrade to a plan with higher resources. This might be expensive, especially if you’re trying to install a complex plugin on a new site. If you don’t yet have a large number of visitors, all of the other resources earned by upgrading will be ineffective.
You may also choose a host like Kinsta, which comes with additional memory out of the box.
Have you come across the dreaded White Screen of Death? Then you might need to increase the PHP memory limit. Click here to see a step-by-step guide.
TO TWEET, CLICK HERE
Summary
The PHP memory restriction is in place for a good reason: you don’t want rogue processes consuming more RAM than they should. However, when you reach your limit and get a white screen of death while running a genuine plugin, it can be rather irritating.
In the end, your host determines how much PHP memory you have. It will be impossible to raise the bar if they set it too low.
However, your site may occasionally use fewer resources than you actually have. In that situation, you may be able to improve your memory. You don’t want it to be too high, so set it to 128 or 256 MB (the default for all Kinsta plans).
If neither of those approaches work, the issue is most likely due to a lack of allocated resources rather than a configuration that needs to be changed. Contact your host and inquire about getting more, or transfer to a new server like Kinsta, which provides you with far more RAM than you’ll ever need.
Save time, money, and improve site performance by using:
Expert WordPress hosting assistance is available 24 hours a day, 7 days a week.
Integration with Cloudflare Enterprise.
With 29 data centers across the world, we can reach a global audience.
With our built-in Application Performance Monitoring, you can improve your performance.
All of this and more is included in a single plan that includes no long-term obligations, aided migrations, and a 30-day money-back guarantee. Check out our plans or speak with a sales representative to find the ideal plan for you.