Is your WordPress website crashing, slow to load, or timing out? Do you see an «Allowed memory size of [number] bytes exhausted» error?
The best way to investigate the cause of memory-related problems is to check your website’s memory usage in real-time. But unless your site runs on a VPS or dedicated server, real-time stats probably aren’t available.
Some web hosts will provide you with a memory usage number in their control panel or account manager. But is that number accurate? When was the usage measured? When does it update?
Today, we’ll talk about a WordPress plugin called Server IP & Memory Usage Display. The cool thing about the plugin is it gives you memory usage numbers that are current at the moment you load the page.
So, if you’re experiencing website problems that may be memory-related, you can check usage while the problem is occurring. Or you can monitor memory usage over a period of time. Then use those numbers to determine whether the memory allocated to the site needs to be adjusted.
We’ll go over plugin installation, and talk about ways you may be able to adjust WordPress memory usage.
The plugin is very easy to install, so let’s get started.
Installing the Server IP & Memory Usage Display Plugin
Log in to your WordPress admin panel.
In the left column navigation, mouse over the «Plugins» link and click the «Add New» link.
In the «Search plugins…» box, enter, «Server IP & Memory Usage Display.»
When you find the plugin, click the «Install Now» button.
Now the plugin is installed, but it has to be activated before you can use it.
Click the «Activate» button.
That’s all there is to it. Now let’s see how the plugin works.
How to View Server Memory Usage Data
Once the plugin is installed and activated, it’s working. There’s nothing to set up or configure.
It will display memory and IP data at the bottom of every WordPress admin page.
Let’s take a look at that data.
In our demo here, the memory use looks like this:
Memory: 6 of 128 MB (5%)
Let’s break that down.
- It’s telling us that we were using 6 MB of memory when the page loaded.
- Then it’s showing us the memory limit for the website, 128 MB. That limit is usually imposed by your web host as part of your hosting plan limits.
- Finally, the percentage of use of your memory quota. In our example, WordPress was using 5% of the memory available for the hosting account.
This is the maximum amount of memory that WordPress can use. (Technically, it’s the maximum amount of memory the WordPress PHP functions can use.) In our case, it’s set to 40 MB:
WP LIMIT: 40 MB
That’s the default setting when you install WordPress. But it’s a WordPress configuration limit, not a server limit, so it’s possible to change it in the wp-config.php file.
Let’s try to raise that value to 64 MB and see what happens.
To increase the value, we have to make a change to the wp-config.php file. The file is located in the root directory of your WordPress installation. So if you installed WordPress into a directory named blog, for example, you’d look for /blog/wp-config.php.
I’m going to download and upload the file using FTP. But if you prefer, you can use something like the cPanel file manager if it’s available to you.
Connect to your site and find the wp-config.php file.
Download it and open it in your text editor. (If you’re using a web-based file manager, you can probably edit the file without downloading it.)
Add this line:
[ht_message mstyle=»info» title=»» show_icon=»» id=»» class=»» style=»» ]define( ‘WP_MEMORY_LIMIT’, ’64M’ );[/ht_message]
Save the file and upload it to the server.
Now, if I go back to my WordPress admin area and reload a page, we should see the change.
And there it is.
Note: In some cases, your hosting space may have less memory allocated to it than this setting specifies. (Meaning less than 40 MB.) Under those circumstances, WordPress could potentially use all of the memory available for your hosting space.
A value less than 40 MB would be an unusually low memory allocation for a modern hosting account. Still, if you ever need to adjust for a smaller memory quota, the WP_MEMORY_LIMIT value can be set lower than 40 MB.
The last two values displayed by the plugin aren’t related to memory usage. The first is IP. The plugin uses PHP to get the server IP address and hostname and show them.
This information could be useful if you manage several WordPress installations on different servers.
The final value displayed, the PHP section shows the current PHP version the website is using. The section also shows some very basic operating system information.
The PHP version can be valuable information since WordPress has a minimum PHP version requirement. That won’t usually be an issue. But if you installed WordPress years ago and are having trouble updating, you may have to update PHP.
If the PHP version displayed here is lower than the WordPress recommendation, contact your host. They will be able to point you in the direction of a PHP version control or update it for you.
What Causes WordPress Memory Errors or Problems?
You might assume memory errors happen because the website is very busy serving a lot of visitors. That’s certainly one thing that can cause errors, but it’s not the most common cause.
More often than not, memory errors are caused by plugins and themes. Memory can be an issue if you use a large number of plugins. But it can also be an issue if you use one poorly coded plugin or theme.
Plugins are great. They’re what makes WordPress such a flexible platform. But not all plugins are written by professional developers. And if a plugin developer makes a mistake, and then you install the plugin, your website just inherited that mistake. The only way to troubleshoot suspected plugin problems is to disable plugins one by one to locate the tool causing the issue.
It’s important to remember that increasing the memory limits is not a good way to deal with a bad plugin. If you think a plugin is causing memory problems, delete it and try to find a better replacement.
If You Need More Memory for WordPress Admin Tasks
We talked about raising the memory limit for WordPress in general. That can fix a lot of crashing problems and «Allowed memory size of [number] bytes exhausted» errors.
But what if you only experience errors when performing administrative tasks in WordPress? By that, I mean things like updates or running tasks via plugins, etc. If that’s a problem you run in to, you can set a higher memory limit that applies only to the admin section of WordPress.
Since admin tasks are only done occasionally and for brief periods, you may want to let them use more memory.
Here’s how to do it.
Remember increasing the WP_MEMORY_LIMIT value in wp-config.php? We increase the admin memory limit the same way.
So open up wp-config.php and add this line:
[ht_message mstyle=»info» title=»» show_icon=»» id=»» class=»» style=»» ]define( ‘WP_MAX_MEMORY_LIMIT’, ‘128M’ );[/ht_message]
Adjusting the 128MB to your desired setting, of course.
So, if you were adding a higher admin limit to the wp-config.php file we edited earlier, it would look like this:
What that does is tell WordPress it can use 64 MB of memory for the public side, and 128 MB for admin tasks.
What Happens if You Uninstall the Server IP & Memory Usage Display Plugin
If you uninstall the plugin, the memory and server data will no longer be displayed. No other parts of WordPress are affected.
Keep an Eye on Memory Usage as a Preventative Measure
Even if you aren’t having a memory-related problem, it’s good to look at memory usage from time to time. If you do, you’ll notice when memory usage increases, and you’ll be better able to determine the cause. Did you see memory use jump after installing a new plugin? You can be pretty sure what the culprit is.
Watching memory usage can also alert you that it’s time to upgrade your hosting plan. Seeing a steady increase in memory use along with an increase in visitors is normal. As far as problems go, I think accommodating more visitors is a problem we’d all be happy to deal with.
Have you ever had to troubleshoot WordPress memory errors? What did you do about them? Has a poorly written plugin ever caused you any grief? Let me know in the comments.