If you own a WordPress site, then you might face random crashes or server errors on your website due to high resource or memory usage.
This guide explains some of the key points that you can consider and fixes to apply when experiencing issues related to high memory usage on your WordPress site.
Fix Memory Leaks by Poorly Coded Plugins
Badly coded plugins can be responsible for leaking memory and consuming all of the server’s memory. This can cause 500 errors or server crashes randomly.
Deactivate Plugins with High Memory Usage
In this case, you can try deactivating plugins from “Plugins” > “Installed Plugins” one at a time to find which plugin is causing the memory to be utilized fully.
If you can’t access the WordPress admin for deactivating plugins, then you can also deactivate the plugin by using the file manager of your cPanel or web control panel.
Deactivate Plugins using File Manager
To deactivate plugins using the file manager, navigate to your WordPress files, then go to the “plugins” folder inside the “wp-content” that is “wp-content/plugins”. Here, you will find a list of plugins, for example:
You can simply rename the folder name of the plugin to deactivate it. For example, if we add “-o” after the “jetpack”. Then, this will deactivate the Jetpack plugin.
After deactivating plugins one at a time, you can try to access the WordPress admin dashboard. You can repeat these steps for each plugin to find the plugin that causes memory errors.
Also, you may deactivate all of your plugins by renaming all of the folders if you still can’t access the wp-admin dashboard. Once, you are able to access the WordPress admin dashboard, you can rename them back to the original folder names.
Note that, simply renaming back to the original folder names of the plugins will not reactivate them. You must activate them again using the WordPress admin panel from “Plugins” > “Installed Plugins”.
For your WordPress site, it is recommended to install only well-coded plugins from reputed providers that are actively maintained and do not leave any residual or memory leak.
Increase PHP Memory Limit
If your WordPress website is an eCommerce store and has plugins like WooCommerce, then it might consume so much memory.
Generally, the PHP memory limit is 128MB or 256MB. You may increase this PHP memory limit to 512MB or 1GB to see if that fixes random errors due to memory usage on your website.
As an example, to increase the PHP memory limit using cPanel, navigate to “Select PHP Version” under the “Software” section. Then, go to the options where you find the memory limit value for the PHP as shown below:
You can increase this memory limit value to 512M or 1G.
Increase Physical Memory and I/O Limit
Besides the PHP memory limit, there is also an actual physical memory that you may need to increase to 512 MB or 1 GB as well. You can’t simply change it via cPanel. To increase that value, you might need to contact your hosting provider.
The physical memory usage and its current value are visible in the cPanel under the “Statistics” section.
Along with the physical memory, you can also ask your hosting provider to increase the I/O limit. It is the maximum speed of data transfer between the hard disk and the RAM.
The low I/O limit can cause the freezing of a website while it waits for data to transfer from the hard disk to the RAM.
Increasing the I/O limit can reduce the delay in loading a website. For eCommerce stores having WooCommerce, it’s great to increase the I/O limit to 10 MB/s.
Use Caching Plugins to Reduce Server Load
For a website with high traffic, using caching mechanism can help reduce the server load. Also, using caching can help improve the performance of a website significantly.
Caching reduces memory usage, CPU, and overall load on the server. It can help to fight against DDoS attacks. Also, it can fix random errors that may occur due to high resource usage.
There are many caching and optimization plugins available to use for a WordPress website. One thing to note is you should not activate more than one caching plugin at the same time for the same type of caching.
Upgrade WordPress and PHP Version
Keeping WordPress up to date along with all the plugins and themes may also fix issues related to high memory usage on a WordPress site. Before upgrading to any major version, the backup must be taken beforehand.
PHP is constantly evolving with its performance and new features. So, it is a good practice to make sure the PHP version that you use for your WordPress site remains up-to-date to a version that is actively maintained for security releases.
Before you upgrade PHP on your site, you should make sure all plugins and the theme that you use are compatible with the PHP version that you are going to upgrade to.
Disable XMLRPC and Improve WordPress Security
There are many bots crawling the internet that target WordPress-based sites. Having many bots crawling your WordPress site for vulnerability can slow it down or may cause high resource usage.
Therefore, it is crucial to have a firewall plugin activated or some type of server firewall to protect your WordPress site.
You should disable access to the “xmlrpc.php” file which is the most commonly targeted by the bots that may result in slowing down the WordPress site. There are many ways to disable access to “xmlrpc.php” by using a plugin or directly blocking it via the “.htaccess” file or a similar mechanism. Also, you should secure your WordPress login by using a captcha security plugin or firewall whitelist.
So, all these points are important considerations to reduce high memory usage or resource usage for a WordPress website.