Thursday, January 30, 2025
HomeWordPress NewsHow to Increase WordPress Memory Limit

How to Increase WordPress Memory Limit


Is your WordPress site displaying the “Fatal error: Allowed memory size exhausted” message? This common error occurs when your site needs more memory than the default 32MB limit allows. Learning how to increase WordPress memory limit can solve this issue and keep your site running smoothly. From editing configuration files to using plugins, there are several ways to fix this problem. 

In this guide, we’ll walk through five proven methods to increase your WordPress memory limit, helping you choose the best solution for your site.

How to Increase WordPress Memory Limit


Table of Contents

  1. Why Memory Limit Errors Occur in WordPress
  2. How to Check Your Current Memory Limit
  3. Method 1: Edit wp-config.php File
  4. Method 2: Modify the PHP.ini File
  5. Method 3: Update .htaccess File
  6. When to Contact Your Host

Why Memory Limit Errors Occur in WordPress

Memory in WordPress serves to manage the execution of scripts, plugins, and media processing. By default, WordPress starts with a 32MB memory limit, which is typically sufficient for simple sites but often inadequate for modern, resource-intensive platforms.

When your site hits its memory cap, WordPress tries to automatically adjust it—up to 40MB for single sites and 64MB for multisite installations. However, if the required memory exceeds these thresholds, you’ll encounter errors like the memory exhausted error message.

Common Causes of Memory Limit Errors

  1. Database Queries. Complex database queries, especially those generated by plugins or custom themes, can demand excessive memory. Poorly optimized queries or large datasets further strain memory.
  2. PHP Version. Running outdated PHP versions, such as PHP 5.x, can result in inefficient memory usage compared to newer versions like PHP 8.x.
  3. Heavy Plugins and Themes. Plugins with a lot of functionality or high-resource themes often consume large amounts of memory, exacerbating the memory limit issue.
  4. Increased Site Traffic. Higher traffic increases server load as WordPress dynamically generates content for each user request, driving up memory consumption.
  5. Large Media Files. Uploading large media files such as videos and high-resolution images can temporarily spike memory usage during processing.
  6. Autoloaded Data. Some plugins load unnecessary data into memory, even if not required on every page visit, resulting in increased memory demands.

How Much Memory Does Your Site Need?

For most WordPress sites, a memory limit between 128MB and 256MB is typically sufficient. However, resource-heavy sites—such as e-commerce stores or membership platforms—might require up to 512MB, depending on factors like traffic volume, plugin count, and media complexity.


How to Check Your Current Memory Limit

Before attempting to increase your WordPress memory limit, it’s essential to know your site’s current limit. This can help you decide how much more memory your site may require and ensure that your changes have taken effect. Fortunately, checking your WordPress memory limit is straightforward and can be done directly from your WordPress admin dashboard.

1. Log in to your WordPress admin dashboard.

2. Go to Tools > Site Health.

Site HealthSite Health

3. Click on the Info tab at the top.

Site Health - InfoSite Health - Info

4. Scroll down to the Server section in the Site Health Info page.

Look for the field labeled PHP memory limit. This shows your site’s current memory allocation.

Site Health - PHP memory limitSite Health - PHP memory limit

However, simply increasing the limit isn’t always the best solution – you should also focus on optimizing your site’s performance through proper maintenance and cleanup.


With a clear understanding of memory limits and their impact, it’s time to fix the issue. Below, we outline simple and effective methods to increase your WordPress memory limit and keep your site running smoothly.

Method 1: Edit wp-config.php File

Editing the wp-config.php file is the most direct way to increase your WordPress memory limit. This file controls your site’s core settings and is located in your WordPress root directory. Before making any changes, create a backup of your site to prevent potential issues.

Follow these steps to modify your memory limit:

1. Access Your WordPress Files. First, connect to your website using an FTP client like FileZilla, or use your hosting provider’s file manager. Navigate to your site’s root directory (usually public_html or www).

2. Locate wp-config.php. Find the wp-config.php file in your root directory. This file contains critical WordPress configuration settings. Download a backup copy to your computer before making any changes.

wp-config.php filewp-config.php file

3. Add the Memory Limit Code. Open wp-config.php in a text editor and look for this line:

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

If you find it, change the value to your desired limit. If you don’t see this line, add it before the line that says “/* That’s all, stop editing! Happy publishing. */“:

WordPress memory limit in wp-config.phpWordPress memory limit in wp-config.php

4. Save and Upload. Save your changes and upload the modified file back to your server. Clear your browser cache and refresh your WordPress admin area.

Important Considerations:

  • Don’t set the limit higher than your hosting plan allows
  • Start with 128M or 256M before trying larger values
  • Some hosts may override these settings
  • If you can’t save changes, check file permissions

If you get a server error after making these changes, immediately restore your backup copy of wp-config.php. Not all hosting environments allow memory limit adjustments through this method.


Upgrade Your Website with a Premium WordPress Theme

Find a theme that you love and get a 20% discount at checkout with the FLASH20 code

Choose your theme

blog cta bg 2blog cta bg 2

Method 2: Modify the PHP.ini File

If editing wp-config.php doesn’t resolve your memory issues, you can try adjusting your server’s PHP.ini file. This method changes PHP settings at the server level, but it may not be available if you’re using shared hosting.

Follow these steps to modify your PHP.ini file:

1. Check Access and Location. Most hosts store the PHP.ini file in your site’s root directory. If you can’t find it, you may need to create one. Some shared hosting providers offer PHP settings in their control panel instead.

2. Locate or Create PHP.ini. If you need to create a new PHP.ini file, use a text editor to create a blank file named ‘php.ini‘. Add these lines:

memory_limit = 256M
upload_max_filesize = 64M
post_max_size = 64M
max_execution_time = 300
max_input_time = 300

If the file exists, find these lines and update their values:

memory_limit = 256M

Key Settings to Consider:

  • memory_limit should be the largest value
  • post_max_size should be larger than upload_max_filesize
  • max_execution_time affects how long scripts can run

4. Save and Test. Upload the file to your root directory. Your hosting server may need to restart for changes to take effect. Test your site to ensure everything works correctly.

Troubleshooting Tips:

  • If changes don’t work, your host may have restrictions
  • Check your hosting control panel for PHP settings
  • Some hosts require support tickets for PHP changes
  • Verify file permissions are set correctly

Remember to clear your browser cache and restart your WordPress admin session after making these changes.


Method 3: Update .htaccess File

The .htaccess file offers another way to increase your WordPress memory limit, particularly useful when you don’t have access to PHP.ini. This method works on Apache servers and serves as a last resort if other methods fail.

Step-by-Step Process:

1. Find Your .htaccess File. Connect to your site via FTP and locate the .htaccess file in your WordPress root directory. Since it’s a hidden file, you might need to enable ‘Show Hidden Files’ in your FTP client.

2. Create a Backup. Before making any changes, download a copy of your current .htaccess file. If something goes wrong, you can quickly restore this backup.

3. Add Memory Limit Rules. Add these lines at the end of your .htaccess file:

php_value memory_limit 256M
php_value upload_max_filesize 64M
php_value post_max_size 64M
php_value max_execution_time 300

Important Guidelines:

  • Place new rules after any existing WordPress rules
  • Keep the memory_limit higher than other values
  • Don’t exceed your hosting plan’s maximum limits
  • Maintain proper file permissions (usually 644)

4. Test Your Site. After saving changes, check your site immediately. If you see a 500 Internal Server Error:

  • Remove the added lines immediately
  • Restore your backup .htaccess file
  • Try smaller memory values
  • Contact your host for supported limits

Common Issues and Solutions:

  • If changes don’t work, your host might not allow .htaccess overrides
  • Some hosts require different syntax for these rules
  • Server configurations might block certain PHP values
  • Shared hosting often has stricter limitations

Remember to clear your cache and test your site thoroughly after making these changes. If problems persist, revert to your backup file and try a different method.


If you’ve tried the methods outlined in this guide and are still encountering WordPress memory limit errors, it may be time to contact your hosting provider. Your host can help you diagnose the issue and provide guidance on the best solution for your specific setup.

Situations where you should reach out to your host include:

  • You don’t have access to your site’s wp-config.php, php.ini, or .htaccess files
  • Editing these files doesn’t resolve the memory limit error
  • You’re unsure of the appropriate memory limit value for your site
  • Your site is on a shared hosting plan and you’re worried about exceeding your plan’s resources

When contacting your host, be sure to provide as much detail as possible about the issues you’re experiencing and the steps you’ve already taken to troubleshoot the problem. This will help your host provide more targeted assistance.

Some hosting providers offer managed WordPress hosting plans that include automatic memory limit increases and other performance optimizations. If you’re frequently running into memory limit issues or want a more hands-off approach to managing your site’s resources, consider upgrading to a managed WordPress hosting plan.


Boost Your WordPress Site with WPZOOM Themes

Now that you’ve resolved your WordPress memory limit issues, it’s time to focus on enhancing your site’s performance and design. WPZOOM offers lightweight, customizable themes like Inspiro Premium that are optimized for speed and functionality.

With our premium themes, you can unlock advanced features to take your site to the next level—without compromising on performance.



Source link

RELATED ARTICLES
Continue to the category

LEAVE A REPLY

Please enter your comment!
Please enter your name here


Most Popular

Recent Comments