20i
How to resolve WordPress memory limit issues

How To Resolve WordPress Memory Limit Issues

Some of the common challenges WordPress users face revolve around memory related issues.

WordPress memory limit is a defined threshold available for your website without it exceeding the server’s RAM capacity.   

Some scripts can use a lot of memory, especially if a WordPress plugin is used to import a large amount of data. If a script exceeds the memory limit, it could cause your website or server to crash. 

You may have experienced the error message on your website “Allowed memory size exhausted” which generally means that your website has run out of memory – we briefly touched on this in our White Screen Of Death blog post.

In this article, we’ll explore different ways on how you can check the memory limit that your website is set to, how you can increase this and the potential causes.  

How you can check your website’s memory limit 

A phpinfo page will display all the PHP information that you need, including your website’s memory limit. It’s very easy to set up and only requires one line of code.  

Firstly, create a file called phpinfo.php.

You can do this via your File Manager or you can create this locally and upload via FTP.  Add this line of code: 

<?php 

phpinfo( ); 

?> 

Now you can load this in your browser via the URL i.e https://your-domain.com/phpinfo.php.

You should see something like this: 

You can then do a quick find with ‘ctrl+f’ and search for “memory_limit” to find the row showing your website’s memory limit.

How to identify low memory (and how to increase it) 

If you find that your website’s loading speed has decreased (or won’t load at all) and throws back the “Allowed memory size exhausted” error mentioned above, there are various ways you can modify and increase the PHP Memory limit.  

Here are some common examples… 

PHP Configuration in My20i 

You can modify your website’s PHP configurations in My20i via Manage Hosting > Options > Manage > Web Tools 

Click ‘PHP Configuration’ you can then easily modify the PHP Memory limit for your website.

php.ini or .user.ini

If you’ve used the ‘PHP Configuration’ tool in My20i, this will automatically set a directive in the .user.ini file called memory_limit.

This directive sets the maximum amount of memory a PHP script is allowed to allocate, and you can modify the value within the file.

If your website is hosted elsewhere, you’d usually find the file within the root directory of your website files or in the public folder. You can create one if needed using the File Manager or locally and then upload the file via FTP.

wp-config.php

you can define a specific memory limit in the wp-config.php file for WordPress to use. Here is an example:


define('WP_MEMORY_LIMIT', '256M');

.htaccess

The .htaccess file can also be used to set PHP values, including the memory limit. Adding this line will set the memory limit:

php_value memory_limit 256M

Causes and Preventative measures

Cache Configuration

Configuring your website to cache will help reduce memory issues, especially if your website receives a high amount of traffic.

If you have a busy website without caching, it can greatly impact your servers’ resources as the page will need to be generated from the origin server.

Caching stores static content, which is delivered much more quickly and has zero impact on your server resources.

At 20i, our Reseller hosting and 20iCloud servers include our own fully featured CDN and bespoke cache plugin for Managed WordPress.

Use well maintained Plugins and Themes

Poorly coded plugins and themes can cause memory issues for your website. When choosing your websites plugins and themes, be sure to check out how often they’re updated.

If a plugin or theme has not been updated for a long time, it’s likely to have fallen behind with WordPress core updates and conflict, causing performance and security issues for the website.

Bot Traffic and DDOS Attacks

Anti-DDoS attacks and Bot Traffic can overwhelm the server resources, causing your website to go down.

At 20i, all our hosting platforms feature 1+tbps Anti-DDoS and bad bot protection at no extra cost.

Inadequate Server Resources

Your website may naturally require more RAM. With our Managed Cloud Hosting you can monitor your website’s memory usage via the server management page within My20i. You can easily upgrade your server specification if needed.

For websites hosted on our Reseller hosting platform, resources are scaled on demand so you will not be hit by LVE limits, ever.

Monitor Memory Usage

There are various ways you can monitor your website’s memory usage. A useful plugin called WP Server Stats will display your website’s PHP memory usage in real time.

This is especially useful if you’ve encountered the dreaded ‘Allowed memory size exhausted’ error message.

If your website is hosted on our Managed Cloud Hosting, you can also monitor the RAM usage within the server management area and identify the website using the most amount of memory.

Final thoughts

Implementing preventative measures such as optimising your website’s code and configuring your website to cache will make your website resilient against memory issues.  

Monitoring your WordPress website using the WP Server Stats plugin will also keep you one step ahead.  

Managed WordPress Hosting

Add comment

Ben Perry

Profile Picture For Ben Perry

Ben is a Technical Salesperson at 20i. He has a keen interest in cyber security, which he explores in his rare free time when not entertaining his toddler.

Follow us

Let's get social! Awesome content, offers & exclusive competitions.