In this post, we have shown you not only how to fix the WordPress memory exhausted error but also how to build a resilient and high-performing website. After fixing the error, you can optimize your site by implementing a couple of best practices to prevent this in the future.php_value memory_limit 256M
Suggested read: How to Find the Most Used Disk Space Directories and Files in LinuxIn this guide, we will walk you through everything you need to know to solve the “memory size exhausted” problem for good.The php.ini file is the master configuration file for PHP on your server. Modifying this file changes the memory limit for all PHP applications, not just WordPress, which makes it the most powerful method. However, on shared hosting, you typically do not have access to this file, so this method is primarily for users on a VPS or dedicated server where you have root or sudo privileges.The easiest way is to navigate to “Tools > Site Health” in your WordPress dashboard, click the “Info” tab, and expand the “Server” section. Alternatively, a more direct server-level approach is to create a file named info.php in your root directory containing <?php phpinfo(); ?> to view the master memory_limit value.
Table of Contents
- 1 How to Check Your Current PHP Memory Limit in WordPress
- 2 How to Fix the WordPress Memory Exhausted Error (7 Proven Methods)
- 2.1 1. Increase PHP Memory Limit via wp-config.php File
- 2.2 2. Edit the .htaccess File to Raise Memory Limit
- 2.3 3. Modify the php.ini File on Your Server
- 2.4 4. Use the Hosting Control Panel or the RunCloud Dashboard to Increase Memory
- 2.5 5. Deactivate Heavy or Poorly Coded Plugins
- 2.6 6. Optimize Images and Media Files to Reduce Memory Usage
- 3 Wrapping Up: Best Practices to Prevent the WordPress Memory Exhaustion Error
- 3.1 FAQs on WordPress Memory Exhausted Error
- 3.2 How do I increase PHP memory in WordPress?
- 3.3 What causes memory limit errors in WordPress?
- 3.4 Why does my site crash when uploading images?
- 3.5 How do I find my current PHP memory limit?
- 3.6 Can plugins cause memory exhaustion?
- 3.7 What is the ideal PHP memory limit for WordPress?
- 3.8 How do I fix fatal errors in WordPress?
- 3.9 Does changing themes affect memory usage?
How to Check Your Current PHP Memory Limit in WordPress
Once you have identified a suspect, the safest way to confirm your diagnosis is in a non-production environment. Instead of deactivating plugins on your live site and risking further downtime, use RunCloud’s one-click staging functionality. This creates an identical, isolated copy of your site where you can safely deactivate the suspected plugin and test thoroughly without impacting your visitors. If the error disappears on the staging site, you’ve found your culprit and can proceed with deactivating or replacing it on your live production site.
1. Using the Site Health Tool in the WordPress Dashboard
(Before editing, it is recommended that this file be backed up.)define('WP_MEMORY_LIMIT', '256M');
memory_limit = 256M
Before you can fix a memory exhausted error, you first need to identify your current limit. There are several ways to do this. Sign up for RunCloud today and experience a faster, more stable WordPress site.This is the standard WordPress method for increasing the memory available to your application. The wp-config.php file contains your site’s base configuration and is located in the root directory of your WordPress installation.

Have you ever encountered the “memory size exhausted” message on your website? If yes, then you’ll probably know that this single issue can bring your entire site to a halt.
3. Identifying Memory Limit via Hosting Control Panel (cPanel, RunCloud, etc.)
This is just one example of how RunCloud transforms server management from a reactive chore into a proactive strategy. Suggested read: How to Fix WordPress High CPU Usage (10 Instant Solutions)You’ll learn how to check your current WordPress memory limit and discover proven methods to increase it, whether by editing the wp-config.php file, the .htaccess file, or the master php.ini file.

The most effective method is to edit your wp-config.php file by adding the line define('WP_MEMORY_LIMIT', '256M'); just before the “That’s all, stop editing!” comment. If this doesn’t work, your host may be overriding it, so you can try setting the memory_limit value in your .htaccess or php.ini file.
How to Fix the WordPress Memory Exhausted Error (7 Proven Methods)
Furthermore, a plugin that exhausts memory is frequently a slow-performing one; this is where RunCloud’s built-in slow script monitoring becomes invaluable. It helps you identify scripts that are taking too long to execute and are likely candidates for high memory usage.
1. Increase PHP Memory Limit via wp-config.php File
On a more powerful platform like RunCloud, this information is even more accessible and transparent. Simply navigate to your Web Application > Settings within the RunCloud dashboard.This fatal error simply means that a script on your site (usually from a plugin or theme) required more server memory (RAM) than your web hosting environment was configured to provide.The most reliable way to find the exact path your web server is using is to check the “Loaded Configuration File” line within a phpinfo() page, as explained above. Once you have located and backed up the correct file, you will find and change the following line:With RunCloud, you can enable a highly optimized server-level solution like RunCache (NGINX FastCGI cache) with a single click. This immediately lowers your server’s memory and CPU usage and makes your site significantly faster.

One of the most powerful preventative measures is to reduce your server’s overall workload. Every time a visitor loads a page on your site, WordPress executes PHP scripts and queries the database, all of which consume memory. Caching drastically reduces this workload by storing and serving a static HTML version of your page, bypassing the need for most PHP executions.
2. Edit the .htaccess File to Raise Memory Limit
To prevent this, always optimize and resize your images before uploading them to WordPress using a tool like Photoshop or an online image compressor. You can also use a WordPress plugin that optimizes images on the fly, but be mindful that the optimization plugin itself will also consume resources. By reducing the initial file size, you significantly decrease the amount of memory needed for processing.Suggested read: How to Fix WordPress Stuck in Maintenance Mode? [100% WORKING]First, enable WP_DEBUG in your wp-config.php file to see a more detailed error message that often points to the culprit plugin or theme. If it’s a memory issue, increase the PHP memory limit; otherwise, the standard troubleshooting procedure is to deactivate all plugins and switch to a default theme to isolate the problem.A baseline of 128M is a good starting point for a modern website, but 256M is a safer and more common recommendation. For robust sites, especially those running e-commerce platforms like WooCommerce or numerous plugins, setting the limit to 512 MB is often ideal for preventing memory-related errors.
3. Modify the php.ini File on Your Server
Again, ensure you have a backup before proceeding. Open the .htaccess file and add the following line at the very end of the file:Upgrading to a VPS (Virtual Private Server) gives you dedicated resources and full control over your server environment. With RunCloud managing your VPS, you can easily set your PHP memory limit to 512 MB, 1GB, or whatever your applications require.Suggested read: How to Fix WordPress HTTP Error When Uploading Images (Quick Guide)The safest and most recommended method for novice users is to use the tools provided by your hosting provider or server management panel. These interfaces are designed to prevent the configuration errors that can occur when editing files manually. Most control panels have a section for managing PHP settings where you can select your domain and choose a new memory limit from a dropdown menu.
4. Use the Hosting Control Panel or the RunCloud Dashboard to Increase Memory
In this case, increasing the memory limit will not solve the issue, and you will need to identify the specific component causing the issue without disrupting your live site.Suggested read: How to Check Linux CPU Usage or Utilization (5 Ways)

If you have server access, you must first locate the correct php.ini file, as its location varies significantly by Linux distribution and PHP version. For instance, on a server running Ubuntu or Debian with PHP 8.1 and Apache, the path is /etc/php/8.1/apache2/php.ini. If you’re using NGINX with PHP-FPM, the path would instead be /etc/php/8.1/fpm/php.ini. On distributions like CentOS or AlmaLinux, a common location is simply /etc/php.ini.Memory limit errors occur when a WordPress script, typically from a plugin or theme, requires more RAM than the server has allocated for PHP. This exhaustion is often triggered by resource-intensive functions, poorly coded components, or complex database queries that push the process beyond its allowed memory threshold.
5. Deactivate Heavy or Poorly Coded Plugins
If editing wp-config.php doesn’t work, it may be because your hosting provider has locked that setting at the server level. In some Apache servers, you can also edit the .htaccess file, which is also located in your site’s root directory. This file controls server configurations for your specific directory.One of the most common reasons for memory exhaustion is uploading large, high-resolution images. When you upload a picture, WordPress doesn’t just store it directly; it uses PHP to process it and create multiple smaller versions (thumbnails). This image processing is a very memory-intensive task, and a large file can easily push PHP past its limit.Most modern hosting environments provide a graphical interface to view and manage server settings. In traditional control panels like cPanel, you might find this information under a “MultiPHP INI Editor” or “Select PHP Version” tool. If you are seeing this message, don’t panic. It’s one of the most common issues WordPress users face – and is completely fixable.

The easiest and safest way for any user to check the PHP memory limit is directly within the WordPress dashboard. WordPress has a built-in “Site Health” tool that reports your website’s configuration and server environment.If you have tried all the above methods and are still hitting memory limits, especially on a shared hosting plan, it may be time to upgrade. Shared hosting environments place strict, and often low, caps on resources like RAM to ensure stability for all users on the server. No amount of configuration file editing can overcome a hard limit imposed by your provider.
6. Optimize Images and Media Files to Reduce Memory Usage
Let’s get started!To access it:<?php phpinfo(); ?>
After you make the necessary changes, you can save the settings without any need for SSH or FTP.Here, you will see your current PHP version and its associated memory limit clearly displayed:
Wrapping Up: Best Practices to Prevent the WordPress Memory Exhaustion Error
Suggested read: Scaling RAM & CPU Cores – How They Affect WordPress PerformanceYes, plugins are the most frequent cause of memory exhaustion errors in WordPress. A single poorly coded plugin or too many plugins running complex operations simultaneously (like page builders, backup solutions, or security scanners) can quickly consume all available memory.Image uploads are a memory-intensive process because WordPress must not only receive the file but also process it to create multiple smaller sizes (thumbnails). If the original image is very large or your PHP memory limit is low, this process can easily exceed the allocated memory and trigger a fatal error.Sometimes, the problem isn’t the memory limit itself, but a single plugin consuming an excessive amount of resources. A poorly coded plugin or a feature-heavy one (like a page builder or a complex backup solution) can easily trigger a memory error by creating a memory leak or simply by performing a task that is too resource-intensive for your server’s configuration. Suggested read: How to Fix WordPress Revisions Not Showing [SOLVED]
FAQs on WordPress Memory Exhausted Error
How do I increase PHP memory in WordPress?
What causes memory limit errors in WordPress?
info.php in your website’s root directory using an FTP client or a file manager, and place the following single line of code inside it: