The “Memory Limit Exceeded” error in WordPress is one of the most common errors that many users encounter when installing plugins, themes, or performing heavy operations such as demo imports. This error is usually displayed as follows:
Fatal error: Allowed memory size of x bytes exhausted
In this tutorial, we will examine the reasons for this error and explain practical methods to fix it step by step.
What is a Memory Limit Error?
WordPress needs memory (RAM) to execute files and process information. This memory is limited by PHP settings. If a plugin or process exceeds this amount, you will encounter the “Memory Limit Exceeded” error. What exactly does this error mean?
WordPress relies on the PHP programming language to run. PHP, like any other software, requires a certain amount of memory to run. On hosting servers, to prevent excessive resource consumption, each program is allocated a limited amount of memory.
When your site’s load increases or the number of installed plugins becomes large, this memory may be exhausted, and PHP will no longer be able to continue processing. As a result, you will encounter a Memory Limit error like the following:

Common Symptoms of Memory Limit Error:
- White Screen of Death
- Inability to install themes or plugins
- Error when logging into the WordPress dashboard
- Stalling while uploading media or files
Methods to Fix Memory Limit Error
1. Increasing Memory via the wp-config.php
file
- Log in to your hosting account and edit the
wp-config.php
file. - Add the following code before the line
/* That's all, stop editing! Happy publishing. */
:
define('WP_MEMORY_LIMIT', '256M');
The value 256M means allocating 256 megabytes of memory. If the problem persists, you can increase it to 512M.
2. Increasing Memory via the .htaccess
File
If your hosting uses Apache, you can open the .htaccess
file in the root of your site and add the following line:
php_value memory_limit 256M
This method is disabled on some hosts and may result in a 500 error; so use it with caution.
3. Increasing Memory via the php.ini
File
On hosts where you have access to the php.ini
file (especially on VPS or dedicated servers), you can edit this file and add or increase the value of the following line:
memory_limit = 256M
If the php.ini file does not exist, you can create it and place it in the main WordPress directory.
4. Using cPanel (on Hosting with Control Panel)
- Log in to cPanel
- Go to the Select PHP Version or MultiPHP INI Editor section
- Increase the PHP memory in the
memory_limit
section to 256M or higher
5. Contacting Hosting Support
If none of the above methods work, your access to change the memory might be limited. In this case:
- Contact your hosting support
- Request an increase in the PHP Memory Limit to the required amount (e.g., 512M)
Important Tips for Fixing the Memory Limit Error in WordPress
Fixing the “Allowed memory size exhausted” error is not just about increasing PHP memory. To prevent this error from recurring and maintain optimal site performance, following these tips is very important:
1. Always Back Up Your Site Before Making Any Changes
Before editing files like wp-config.php
or deactivating plugins, be sure to create a complete backup of your site’s files and database.
Recommended backup tools:
- UpdraftPlus
- All-in-One WP Migration
- Or use the Backup section in your hosting control panel (CPanel or DirectAdmin)
If errors occur or the site breaks after making changes, you can easily restore the site to its previous state.
3. Use Lightweight and Optimized Themes and Plugins
Heavy or poorly optimized themes and plugins are a major cause of excessive resource consumption.
Suggestions:
- Use professional, lightweight themes with active support (such as: Astra, GeneratePress, Hello Elementor)
- Choose plugins with clean code and compatible with the latest version of PHP and WordPress.
3. Check Plugin Memory Usage
Some plugins, especially page builders or demo importers, consume a lot of memory.
Tools for checking resource usage:
- Query Monitor plugin (to view plugin resource consumption)
- Check the browser console and resources loaded in the Network tab
- Hosting monitoring tools (such as the Resource Usage tool in cPanel)
Plugins that may consume a lot of memory:
- Elementor and its add-on widgets
- WPBakery Page Builder
- Revolution Slider or LayerSlider
- Demo import plugins or heavy installation packages
- WooCommerce with a large number of add-ons
If a plugin is consuming too much memory, it is better to replace it with a lighter alternative or optimize its settings.
4. Recommended Minimum Memory for E-commerce and Multilingual Sites
Websites with heavy plugins such as WooCommerce, WPML, or booking, email marketing, and reporting tools require more memory.
Site Type | Recommended Minimum PHP Memory |
---|---|
Simple Personal or Corporate Website | 128MB |
Blog Website with Moderate Traffic | 256MB |
E-commerce or Multilingual (WooCommerce + WPML) | 512MB |
Website with Heavy Imports or Reporting | 768MB or more |
Setting
WP_MEMORY_LIMIT
andWP_MAX_MEMORY_LIMIT
according to the type of website is essential. Also, check that your hosting supports this level of resources.
Additional Tips to Prevent Errors in the Future:
- Upgrade the PHP version of your hosting to the latest stable version (usually PHP 8.1 or 8.2).
- Use page and file caching to reduce the load on PHP (plugins like LiteSpeed Cache or WP Rocket).
- Optimize or disable the WordPress Cron system and use the server’s Cron system.
- Check PHP error logs and prevent chronic errors (
error_log
in the site root or inside public_html).
Summary
The Memory Limit error indicates that there is insufficient PHP memory to run WordPress scripts. By adding a few lines of code to the core files or changing the settings in the hosting control panel, you can fix this problem in less than a few minutes. If you have just launched your website, be sure to read the content of Comprehensive Step-by-Step Guide to Launching a Website: Must Read!.
If you need support or do not have access to some files, the best course of action is to contact your hosting support and request a memory increase to avoid the Memory Limit error.
Frequently Asked Questions
1. What exactly does the Memory Limit error mean?
The Memory Limit error indicates that your site’s PHP scripts have consumed more than the allowed amount of memory. As a result, the PHP process is stopped and an error is displayed.
2. Why Does the Memory Limit Error Occur More Often in Shared Hosting?
In shared hosting, server resources like RAM and CPU are divided among multiple websites. Therefore, the amount of memory allocated to each site is limited, and this limitation becomes apparent when the site is under excessive pressure.
3. Is Increasing PHP Memory a Risk to the Site?
If done with a logical and proportionate amount, no. However, allocating excessive memory (e.g., more than 1GB without a technical reason) may disrupt the overall server performance. Always use optimized and tested numbers (e.g., 256M or 512M).
4. Does Increasing Memory Solve the Problem Permanently?
No, if the root cause of memory consumption remains (e.g., a heavy plugin or incorrect settings), the error may reappear. Increasing memory is an immediate solution, but you should also identify and fix the root cause of high resource consumption.
5. How Do We Know Which Plugin or Theme Has High Memory Consumption?
You can use plugins like Query Monitor to identify heavy processes, slow queries, or plugins with high resource consumption.
6. Is it possible that the hosting company does not allow increasing the memory?
Yes. Some hosting companies set a specific limit for PHP memory to maintain server stability. If manual modification is not effective, you should contact the hosting support and request a memory increase.
7. Does the PHP version affect this error?
Yes, newer versions of PHP perform better and consume memory more efficiently. It is recommended to use the latest stable version (e.g., PHP 8.1 or higher).
8. How do I know how much PHP memory my site currently has?
You can view the current memory value (memory_limit
) by installing a plugin like Site Health or running the phpinfo()
function in a separate PHP file.