How to Increase WordPress Memory Limit? (Fix it Now)

Here’s a scenario for you. You’re adding cool content and media to your website to make it more captivating and user-friendly. Then suddenly, you see the message: “Fatal error: Allowed memory size exhausted”. It can be quite disheartening to see when you’re trying to create and launch a high-quality WordPress website.

Well, believe it or not, we’ve all encountered the WordPress memory limit error. It is, in fact, a prevalent cause for one of the most common WordPress errors, the White Screen of Death. So, how to increase WordPress memory limit?

With help from our WordPress developers, I have compiled a list of methods you can opt for to increase the WordPress website memory limit for your website. But before you try to learn how to increase the WordPress memory limit, you need to understand what it is and what’s the error associated with it.

What is a WordPress Memory Limit?

A WordPress Memory Limit refers to the maximum amount of system memory (RAM) that WordPress is allowed to use when running on a web server. The memory limit can be found in the “Tools” section of the WordPress admin dashboard. It serves as a safeguard to prevent WordPress from consuming excessive server resources, which could potentially lead to server crashes or poor website performance.

The default memory offered by WordPress is 32MB. However, WordPress needs more memory to store and process data when performing website tasks like running plugins or executing complex scripts. So, sometimes, the memory limit may be exceeded due to resource-intensive operations. In that case, you may see the message “Fatal Error: Allowed memory size exhausted”. That will cause your website to malfunction or even become temporarily unavailable.

Increasing the WordPress memory limit means allocating more memory to the CMS for handling larger media files, resource-intensive plugins, or extensive databases. In short, it allows WordPress to take care of complex tasks more efficiently and smoothly.

How to Check the Memory Limit in WordPress?

Checking the memory limit is quite easy with the easily-accessible WordPress admin dashboard. Here’s how you process before increasing the WordPress memory limit.

Step 1: Log in to your WordPress admin area.

wordPress site health screen : how to increase wordpress memory limit

Step 2: In the left-hand menu, navigate to “Tools” and click on “Site Health.”

info-server

Step 3: In the Site Health screen, click on the “Info” tab and navigate to the “Server” drop-down option.

server settings php memory limit

Step 4: Under “Server,” you’ll see the “PHP memory limit” value listed. This will show your current PHP memory limit.

Alternatively, you can install the plugin WP-ServerInfo and find the menu item labeled “Serverinfo” in your WordPress dashboard. Then, you’ll see various server-related information, including the “Memory Limit” value.

Another way to check the WordPress memory limit is by creating a file “phpinfo.php” in the text editor with the following code excerpt.

<?php phpinfo(); ?>

Upload this file to your root directory through FTP or file manager. Then, in the browser, type in the link ‘http://yoursite.com/phpinfo.php’, with your website’s domain name.

That will display a comprehensive PHP info page including your WordPress memory limit.

Note: Make sure you remove the ‘phpinfo.php’ file from your server after checking the memory limit. It can expose sensitive server information to potential security threats if left accessible.

How to Increase WordPress Memory Limit?

WordPress relies on PHP to execute its scripts and manage memory. So, editing PHP files like wp-config.php and php.ini or using dedicated WordPress plugins can help increase the WordPress memory limit. That will ensure a smoother, more efficient website experience for both you and your visitors.

ways to increase wordpress memory limit

#1 Edit the wp-config.php File

The most common method of increasing the WordPress memory limit is to edit the ‘wp-config.php’ file, located in the WordPress file and directory structure. Here’s how you edit the wp-config.php file of your WordPress.

wp-config view edit

Step 1: Access your web server via an FTP client (or maybe an SFTP or file manager).

Step 2: Locate the wp-config.php file in the root directory of your WordPress installation.

Step 3: Download a backup of the wp-config.php file for safety.

Step 4: Open the ‘wp-config.php’ file with text editors like Notepad.

config.php file wpmet how to increase memory limit

Step 5: Add the following code excerpt just before the line “That’s all, stop editing! Happy blogging.”

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

You can replace ‘256M’ with the desired memory limit (e.g., ‘128M’ or ‘512M’).

After completing the above-mentioned process, save the changes and upload the modified wp-config.php file back to your server.

The wp-config.php file is one of the three critical configuration files for any WordPress website. So make sure you understand PHP coding while editing it. If not, I recommend you get in touch with professional WordPress developers. They’ll help you increase the WordPress memory limit by editing the wp-config.php file.

#2 Through the Hosting Provider

One of the best ways to increase the PHP memory limit is through the WordPress hosting provider. You may contact their support team and request an adjustment to the PHP memory limit for your WordPress site. Here’s the process for increasing the WordPress memory limit via the hosting provider.

Step 1: Log into your hosting account.

Step 2: Look for a “Support” or “Help” section within your hosting account dashboard. The exact location may vary based on your hosting provider’s interface.

If you can’t find the support options within your account, visit the hosting provider’s website and search for a “Contact Us” or “Support” link. This should provide you with contact information or a support ticket system.

Step 3: Reach out to your hosting provider’s support team via email, support ticket, live chat, or phone (whichever method they offer).

Step 4: Specifically request an increase in the PHP memory limit of your WordPress website to your desired value. You can mention a specific limit, such as ‘256M’, if that’s what you need. You can also ask for recommendations for a suitable memory limit based on your hosting plan and site requirements. For example, the PHP memory limit in WordPress VIP is set to 768MB.

Step 5: Then, the hosting provider’s support team will guide you through a set of instructions for increasing the WordPress memory limit for your website. These instructions will perform the change immediately or in a particular time frame.

After you perform this process on how to increase WordPress memory limit, make sure you verify the change has taken effect. You can do so via Tools→Site Health→Server→PHP memory limit.

#3 Create or Edit a php.ini File

Needless to say, you must create a backup of your website before starting this method of increasing the WordPress memory limit. Let’s start the process:

Step 1: First off, check if you already have a ‘php.ini’ file in your WordPress site’s root directory. If you do, proceed to edit it. If not, you’ll need to create one.

For creating a ‘php.ini’ file, use a text editor like TextEdit (on macOS) or Notepad (on Windows). Make sure the file has no extension (e.g., it should be named ‘php.ini’, not ‘php.ini.txt’).

Step 2: Open the ‘php.ini’ file and add the following code excerpt to increase the WordPress memory limit. You can adjust the limit to your desired value, such as ‘256M’ or ‘512M’:

memory_limit = 256M

Step 3: Save the ‘php.ini’ file and upload it to your WordPress site’s root directory. You can do so using an FTP client, your hosting control panel’s file manager, or a similar method.

Step 4: Go to Tools→Site Health→Server→PHP memory limit and check if the changes have taken effect.

Changes to the ‘php.ini’ file should typically take effect immediately. But it’s a good practice to clear your browser’s cache, log out, and log back into your WordPress admin dashboard. That ensures the new memory limit is applied.

#4 Edit the .htaccess File

The ‘.htaccess’ file is a critical configuration file for the website hosts using Apache. It lets you control a lot of your website’s configuration, including its memory limit.

ftp view edit

Step 1: Look for the .htaccess file in your WordPress site’s root directory using FTP or a file manager (in your hosting control panel).

The dot in the front says it’s a hidden file. So make sure your file manager or FTP client is configured to show hidden files.

memory limit

Step 2: Open the ‘.htaccess’ file in a text editor and add the following code excerpt to increase the PHP memory limit of your WordPress website.

php_value memory_limit 256M

You can adjust the limit to your desired value, such as ‘256M’ or ‘512M’

Step 3: After editing the ‘.htaccess’ file, save and verify the memory limit has been increased. You can do so via Tools → Site Health → Server → PHP memory limit.

Finally, clear your browser’s cache, log out, and log back into your WordPress admin dashboard to ensure that the new memory limit is applied.

Disclaimer: This method may not work on all hosting environments. Some hosting providers may disable the ability to change PHP settings via ‘.htaccess’.

#5 Through WordPress Plugin

As with so many other functionalities, you can increase the PHP memory limit by installing a WordPress plugin. One of the common plugins used for increasing the WordPress memory limit is WP Memory. Here’s how to increase WordPress memory limit through a plugin:

Step 1: Log into your WordPress dashboard.

Step 2: On the left side menu, go to “Plugins” and click on “Add New”.

Step 3: Search for “WP memory limit”. Then, choose the best WordPress plugin for increasing the memory limit. 

Step 4: Click on “Install Now”. That will start the installation process. After installing the plugin, click on the “Activate” button to activate it.

Step 5: Once the “WP Memory Limit” plugin is activated, you’ll find a new menu item labeled “Memory Limit” in the WordPress dashboard. Click on it.

Step 6: Now, you’ll see a slider to adjust the memory limit. Slide it to your desired memory limit, such as ‘256M’ or ‘512M’.

Often, these types of WordPress plugins offer the option of “Limit memory allocation”. So you can prevent excessive memory usage by individual PHP processes. That ensures a faulty plugin or theme doesn’t consume all available memory.

Step 7: Save the memory limit and verify the changes via Tools → Site Health → Server→PHP memory limit.

Finally, clear the WordPress cache (and that of the browser) and log back into the admin dashboard to ensure that the new memory limit is applied.

This method can be suitable for those who are uncomfortable editing configuration files or dealing with server settings. However, this method relies on the plugin’s compatibility with your hosting environment, and not all hosting providers or setups may support it.

So, if you encounter issues with the WordPress memory limit plugin or any other one, opt for our WordPress plugin development services. Our experts will work on the plugin to ensure it helps increase the WordPress memory limit effectively.

You may also choose from our WordPress website maintenance packages to handle the day-to-day website issues like memory limits. Our experts will maintain the back end of your website to ensure it runs smoothly and delivers the best performance and user experience.

What is “Fatal Error: Allowed memory size of xxxxx bytes exhausted” in WordPress?

This common WordPress error message indicates that your WordPress site has exceeded its allocated PHP memory limit. It occurs when WordPress and its associated plugins and themes require more memory than what is available.

Fatal error: Allowed memory size of xxxxxx bytes exhausted (tried to allocate xxxxxx bytes) in /path/to/your/wordpress/file.php on line xxx

allowed memory size of xxxxx bytes exhausted error

This fatal error can be triggered by various factors, such as resource-intensive plugins, large image files, or complex operations that require more memory than allocated. To resolve this issue, you need to increase the WordPress memory limit, and there are several ways to achieve that.

But first, you need to understand what causes this error.

Resolve Your Memory Limit Issues with Our WordPress Solutions.

What Causes the WordPress Memory Limit Error?

The memory limit error in WordPress is triggered when your website consumes more PHP memory than the limit set in your server’s PHP configuration allows. Here are a few factors that cause this error:

  1. Resource-Intensive Plugins or Themes: Certain plugins and themes may require significant memory to function correctly. If you have resource-intensive plugins or themes active on your website, they can quickly exhaust the allocated memory.
  2. Large Media Files: Uploading and processing large images or media files can consume a substantial amount of memory, especially if your server has a low memory limit.
  3. Inefficient Code: Poorly coded or inefficiently programmed themes and plugins can be memory hogs. If a plugin or theme doesn’t manage memory properly or has memory leaks, it can lead to memory exhaustion.
  4. Complex Database Queries: Complex database queries, especially on websites with extensive databases, can require more memory. This is often the case for websites with large e-commerce stores or content-heavy platforms.
  5. High Traffic: A sudden surge in website traffic can increase the demand for memory, especially if your website experiences multiple simultaneous requests. High traffic periods can exacerbate memory issues.
  6. PHP Configuration: The server’s PHP configuration settings, including the memory limit, can vary from one hosting provider to another. If your hosting provider has a low default memory limit, it may lead to this error more frequently.
  7. WordPress Core Updates: Occasionally, WordPress core updates or updates to plugins and themes may require more memory to execute successfully. These updates can fail if your site’s memory limit is too low.
  8. PHP Version: Older PHP versions might have lower memory limits. It’s recommended to use a recent PHP version for better performance and to take advantage of improvements.

By addressing these potential causes and increasing the WordPress memory limit, you can minimize the occurrence of the “Fatal Error: Allowed memory size of xxxxx bytes exhausted” error and ensure smoother operation of your website.

Why does WordPress Require a Higher Memory Limit Initially?

WordPress CMS is written and works on PHP. This server-side scripting language needs a large amount of memory to run, depending on a number of factors. Usually, a WordPress website with a few plugins and themes with a moderate amount of traffic will need a memory limit of around 128MB. But for a large or complex website that gets a lot of traffic, you’ll have to increase the WordPress memory limit to 256MB or more.

Here are a few key reasons for WordPress demanding more memory limit:

  1. Plugins: Along with some impressive features and functionalities, WordPress plugins can add to the memory requirements of your website. In essence, the more active plugins, the more memory your WordPress website will need.
  2. Themes: Themes can make your WordPress website more captivating. But more complex themes require more memory to run.
  3. Media files: Media files, like images, videos, and audio files, can also add to the memory limit requirements of your WordPress website. The larger the media files, the more memory they will require.
  4. Active users: The active number of users on your website can also affect the memory requirements. The more active users you have, the more memory your website will need to handle all of the requests.

So, to counter the pros of cool plugins, complex themes, media files, and a higher number of active users, you will need to learn how to increase the WordPress memory limit of your website.

FAQs Related to Increasing the WordPress Memory Limit

What is the default WordPress memory limit?
The default WordPress memory limit is 32MB. However, this may not be enough for some websites, especially those with a lot of plugins, themes, or media files.
How much memory should I increase the WordPress memory limit by?
The amount of memory you need to increase the WordPress memory limit will depend on the size and complexity of your website. A good starting point is to increase the limit to 128MB. If you are still experiencing memory errors, you can increase the limit to 256MB or more.
What happens if I increase the WordPress memory limit too high?
Increasing the WordPress memory limit too high can also cause problems. If you allocate more memory than your server has available, it can cause your website to crash. It is important to consult with your hosting provider to find out how much memory your server has available before increasing the limit.

Conclusion

As standard, WordPress offers 32MB of memory, which may be alright for smaller, more straightforward websites. But as you improve the design and functionality of the website through memory-intensive themes, feature-rich plugins, and more, it will exhaust the pre-allocated memory. 

So follow these processes to increase the WordPress memory limit for a smoother user experience.

  • Editing the wp-config.php file,
  • Contacting the hosting provider,
  • Creating or editing the php.ini file,
  • Editing the .htaccess file or,
  • Installing a WordPress memory limit plugin.

Although two of these methods are quite straightforward, others involve edits in the core code of the CMS. So, if you have any other queries or aren’t comfortable with the process, reach out to our experts today!

To Upgrade Your WordPress Memory Limit with PHP Expertise.

author
Mayur Upadhyay is a tech professional with expertise in Shopify, WordPress, Drupal, Frameworks, jQuery, and more. With a proven track record in web development and eCommerce development.

Leave a comment