With WordPress running millions of websites, you’re bound to run across the “memory exhausted” error at some point, if not already. However, like any sophisticated software, WordPress is prone to problems, but this error is likely caused by your hosting server’s PHP settings not being high enough.

Understanding the error and why?
The “memory exhausted” error occurs when WordPress surpasses the memory limit allocated to it, resulting in a failed execution of a process. By default, WordPress defines a certain amount of memory that can be used by plugins, themes, and scripts to function properly. When this limit is exceeded, it triggers the error, leading to various issues such as blank screens, incomplete content loading, and even website crashes.
So Why?
- Insufficient PHP Memory Limit: WordPress heavily relies on PHP, the programming language that powers it. PHP has its own memory limit, which can be set in the server’s configuration or via the PHP.ini file. If the allocated PHP memory is too low, it can easily be exhausted when running resource-intensive tasks.
- Heavy Resource Usage: Plugins and themes, particularly poorly coded or resource-intensive ones, can significantly increase the memory requirements of your WordPress site. Themes with excessive functionalities or poorly optimized code can consume excessive memory, pushing the site beyond its limits.
- Large Database: WordPress stores website data in a database, and as the size of the database grows, it can demand more memory for processing queries and retrieving information. A large number of plugins or excessive use of media files can contribute to database bloat.
How To Fix?
Increase PHP Memory Limit: The first step to resolving memory exhaustion is to increase the PHP memory limit allocated to your WordPress site. This can be achieved by modifying the PHP.ini file or adding a line of code to the wp-config.php file:
define('WP_MEMORY_LIMIT', '512M');
You can access the wp-config.php file via your FTP client, FileZilla or file manager in cPanel. Consult your hosting provider or website administrator if you’re unsure about making these changes.
Disable or Replace Resource-Intensive Plugins: Identify and disable any plugins or even themes that are causing excessive memory usage. Use the WordPress Health Check plugin or deactivate plugins one by one to pinpoint the culprit. Consider replacing resource-heavy plugins or themes with lighter alternatives that offer similar functionality.
Optimize and Clean Up Your Database: Reduce the size of your database by removing unnecessary data, such as unused plugins, spam comments, and post revisions. Plugins like WP-Optimize or WP-Sweep can assist in optimizing your database and eliminating redundant entries.
Enable Caching: Utilise caching plugins, such as WP Rocket, to reduce the load on your server and improve overall performance. Caching generates static versions of your web pages, allowing faster delivery to visitors and minimizing the need for dynamic PHP processes.
Upgrade Hosting Plan: If your website consistently exceeds the allocated memory limit even after optimizing it, consider upgrading your hosting plan to one that offers more memory resources.
Conclusion
A “memory exhausted” error in WordPress might be aggravating, but it is a fixable problem with the appropriate approach. By understanding the reasons of memory fatigue and adopting the remedies listed above, you can successfully overcome this barrier and guarantee that your WordPress website performs and functions properly.