Home Blog WordPress Management 4 ways to increase WordPress memory limit and improve your site

How to increase the WordPress memory limit

4 ways to increase WordPress memory limit and improve your site

Your site’s running slowly. You’re seeing strange errors. Maybe you’ve even encountered the dreaded White Screen of Death. If your website has slowed to a crawl, then WordPress’ PHP memory limit may be the culprit.

Insufficient memory can lead to a wide range of errors on your WordPress site, including 500 Internal Server Errors or memory exhaustion messages. Increasing the WordPress memory limit can help prevent these errors and stabilize your site. 

There are several methods to increase WordPress memory, and we’re here to walk you through all of them and get your site running smoothly again.

How to know if you’re out of memory in WordPress

If you suspect you’re running out of memory, but aren’t sure, there are several indicators that low memory may be the issue. You may see one of these errors:

1: Fatal error: Allowed memory size of x bytes exhausted – This is a sure sign that whatever you just tried to do exhausted WordPress’ memory limit. Usually you’ll also see some text telling you what file caused your memory to be exhausted.

2: 500 Internal Server Error/HTTP 500 – This indicates that there’s an issue with your server. It can have many causes, with low memory being one.

3: There has been a critical error on this website. – This is another generic error which has many causes, including low memory. Fixing a critical error could involve raising the memory limit.

Critical error on this WordPress website

You may also see a blank white screen, also called the “White Screen of Death”, and be entirely unable to access your site and/or admin area. While there may be no error, this indicates a serious issue on your site that could be related to a memory leak.

Even if you’re not seeing an error, low memory can show itself in other ways. You might encounter noticeably slow performance and loading times. Plugins and themes may struggle to update or perform other functions. Or pages may fail to load completely, leaving out images and other assets.

Upping the memory limit is a quick fix that could potentially solve all of these issues.

What causes the WordPress memory limit error?

Every time WordPress attempts to perform an action, such as executing a plugin script or loading a page, this takes memory. A max amount of memory is allocated to every individual PHP script, and if any exceeds this threshold, you’ll see an error.

Most websites with simple plugins and pages will never need to increase the limit. However, when you start installing complex plugins or attempting to run resource-intensive scripts, you may find the default memory limit causes problems.

If you’re suddenly seeing a memory limit error, here are some possible causes.

  • Resource-intensive plugins and themes – Some plugins and themes are more memory-hungry than others. They may be complex and require more memory to run properly.
  • Inefficient code – Plugins or themes that are poorly coded can use more memory than necessary or even cause memory leaks. You may have accidentally written code that causes a memory leak yourself.
  • Scheduled tasks – WordPress and some plugins run background tasks (like backups, updates, or cron jobs) that consume memory. Resource-intensive tasks can contribute to memory limit errors.
  • Restrictive web hosting – Some web hosts intentionally restrict the memory limit to a very low value and won’t allow you to increase it. This is usually done on shared hosting, so large scripts don’t crash other sites on the network.

How high should I set the WordPress memory limit?

Generally, it’s best to set your memory limit at 64 to start while acknowledging it may need to be increased later.

A higher memory limit doesn’t always mean better performance. Allocating too much memory can make your server struggle with concurrent requests (multiple people visiting your site). It can also lead to wasted memory (which can cost money), and bad actors could exploit the high memory limit to run scripts that crash your server.

It’s better to set the PHP memory limit to no more than you’d realistically need. So what should you set the limit to? Generally, you should go up in increments:

1: 64M – This is suitable for starter sites, like blogs and small business sites, with low traffic and some advanced plugins. Starting here is what’s generally recommended.

2: 128M – Growing blogs and ecommerce sites that experience moderate traffic and use some resource-intensive plugins could consider increasing to 128M.

3: 256M – Large ecommerce sites and high-traffic blogs with complex themes and numerous advanced plugins can consider a memory limit of 256M. This is the default back end memory limit (wp_max_memory_limit), as back end tasks usually need more memory.

4: 512M – Corporate websites with very high traffic and extensive, complicated functionality may need 512M, which is the current maximum allowed for WordPress sites.

5: 1024M – Generally 1024M is excessive for typical websites. Intensive plugins like bulk editing plugins may require this much for the back end.

What’s the difference between WP_MEMORY_LIMIT and WP_MAX_MEMORY_LIMIT?

There are two memory limits you can set in WordPress: wp_memory_limit and wp_max_memory_limit

wp_memory_limit declares the amount of memory WordPress should request for rendering the frontend of the website. The WordPress default is 40 MB for a single site and the WordPress multi-site default is 64 MB. 

Meanwhile, wp_max_memory_limit declares the amount of memory WordPress should request for rendering WordPress admin dashboard. The WordPress default is 256 MB.

You may wish to set the wp_max_memory_limit higher than the wp_memory_limit. Some back end administration tasks require more memory, so setting it higher can help these work properly without overloading the front end with unnecessary RAM.

If you’re having issues with your front end website, increase wp_memory_limit. If you’re having issues with the back end, increase wp_max_memory_limit.

4 ways to increase the WordPress memory limit

There are several ways to increase the memory limit in WordPress, which mostly involve editing sensitive files.

Before you make changes to WordPress website files, you should always backup your website. Take a minute to create a full file and database backup before you follow any of these steps. It’s easy to accidentally change the wrong variable and break your site.

The wp_memory_limit parameter is typically set in the wp-config file, so that’s where we’ll start..

Method 1: Edit the wp-config php file

The first and usually best way to increase the PHP memory limit on your WordPress site is to edit wp-config.php. This is an important configuration file that’s installed alongside WordPress. It controls several parameters, including how much memory is available.

Here’s how you can edit the wp-config.php file using FTP:

1: Obtain your FTP credentials. If your host uses cPanel, log in to cPanel and look for the FTP Accounts tool in the Files section. You’ll find your FTP login credentials here. If you can’t find them, ask your web host for help.

cPanel FTP accounts

2: Install an FTP client like FileZilla. Open FileZilla and enter your FTP credentials, then click Quickconnect.

FileZilla FTP client

3: Locate wp-config.php. It’s usually found in the root directory (usually the directory you’re shown when you connect) or the public_html directory. Right click it and click Edit.

Edit wp-config.php file

4: Find the values define(‘WP_MEMORY_LIMIT’, ’64M’); and define(‘WP_MAX_MEMORY_LIMIT’, ‘256M’);. The numbers shown are just examples; it may be different for you. If you don’t see these values, just paste them in above the “stop editing” line.

5: Increase these values by changing the number (‘64M’ in this example). For example: define(‘WP_MEMORY_LIMIT’, ‘128M’);

Editing memory limit with wp-config.php

6: Save your changes and upload them to the server.

You can also use cPanel to access wp-config.php. Here’s how to do it:

1: Log in to cPanel. In the Files section, look for File Manager and open it.

cPanel File Manager

2: Look for wpconfig.php, usually located in the root directory or the public_html directory. Right click wpconfig.php and click Edit.

Editing wp-config.php on cPanel

3: Find the values define(‘WP_MEMORY_LIMIT’, ’64M’); and define(‘WP_MAX_MEMORY_LIMIT’, ‘256M’);. If you don’t see these values, just paste them above the “stop editing” line.

4: Increase these values by changing the number (‘64M’ in this example). For example: define(‘WP_MEMORY_LIMIT’, ‘128M’);

5: Click Save Changes.

Method 2: Edit php.ini

Another option is to edit php.ini. This is a PHP configuration file which contains many parameters, including ones that control the memory limit in WordPress.

Here’s how to edit php.ini using FTP:

1: Obtain your FTP credentials. If your host uses cPanel, log in to cPanel and look for the FTP Accounts tool in the Files section. You’ll find your FTP login credentials here. If you can’t find them, ask your web host for help.

2: Install an FTP client like FileZilla. Open FileZilla and enter your FTP credentials, then click Quickconnect.

3: Look for php.ini, usually located in the root directory (usually the directory you’re shown when you connect). Right click php.ini and click Edit.

4: Find the values memory_limit = 64M and max_memory_limit = 256M. If you don’t see these values, just paste them in at the bottom.

Memory limit script in php.ini

5: Increase these values by changing the number (‘128M’ in this example). For example: memory_limit = 512M

6: Save your changes and upload them to the server.

Like with wp-config.php, you can also edit php.ini using cPanel. Here’s how to do it.
1: Log in to cPanel. In the Files section, look for File Manager and open it.

2: Look for php.ini, usually located in the root directory or the public_html directory. Right click php.ini and click Edit.

Edit php.ini in cPanel File Manager

3: Find the values memory_limit = 64M and max_memory_limit = 256M. If you don’t see these values, just paste them in at the bottom.

Edit memory using php.ini files on cPanel

4: Increase these values by changing the number (‘64M’ in this example). For example: memory_limit = 128M

5: Click Save Changes.

If you can’t find php.ini, you can just make one – create a file named php.ini in your root WordPress directory, and paste in the memory_limit and max_memory_limit values as shown above.

Method 3: Edit .htaccess

If your web server runs on Apache rather than NGINX, you have a third option: editing the .htaccess file. Note that not all WordPress sites have an .htaccess file, so if you can’t find it, just skip this step.

Here’s how to use FTP to edit .htaccess.

1: Obtain your FTP credentials. If your host uses cPanel, log in to cPanel and look for the FTP Accounts tool in the Files section. If you can’t find your FTP credentials, ask your web host for help.

2: Install an FTP client like FileZilla. Open FileZilla and enter your FTP credentials, then click Quickconnect.

3: You may need to click the Server menu at the top of the app to access server settings, then click Force showing hidden files.

FileZilla force show hidden files

4: Look for .htaccess, typically located in the root directory. Right click .htaccess and click Edit.

Editing .htaccess on FileZilla

5: Find the values php_value memory_limit 64M and php_value max_memory_limit 256M. If you don’t see these values, just paste them in below #END WordPress.

6: Increase these values by changing the number (‘32M’ in this example). For example: php_value memory_limit 128M

7: Save your changes and upload them to the server.

You can also access .htaccess through cPanel similar to other configuration files: 
1: Log in to cPanel. In the Files section, look for File Manager and open it.

2: Look for .htaccess, usually located in the root directory. You may need to click the Settings button in the top right corner and tick Show hidden files.

Show hidden files on .htaccess preferences, cPanel

3: Right click .htaccess and click Edit.

4: Find the values php_value memory_limit 64M and php_value max_memory_limit 256M. If you don’t see these values, just paste them in below #END WordPress.

php_value memory limit

5: Increase these values by changing the number (‘64M’ in this example). For example: php_value memory_limit 128M

6: Click Save Changes.

Method 4: Upgrade your web hosting

Finally, there’s one last method. If none of the above works, the culprit is most likely that your host has locked the memory limit to a strict, low value. Changing the PHP memory limit won’t override any settings your host has configured itself.

You can always ask your web host if they set the limit themselves, and if they’ll raise it for you. If not, your only option is to upgrade your hosting plan.

Even if the host has not artificially lowered the memory limit, you may be using shared hosting that simply doesn’t have enough memory to allocate more. In this case, you’ll also need to upgrade to a better plan with more RAM.

You may be able to switch to a higher tier with more resources. Or you may need to swap to a different type of hosting entirely. For example, VPS and dedicated hosting are both more powerful forms of hosting. If you use cloud hosting, you could just increase how much RAM you have available.

Final thoughts

When your site encounters the memory exhausted error or has slowed to a crawl, a low memory limit could be the culprit. Using the four steps above, you can raise this limit and potentially improve your site’s performance and stability.

Just remember that you shouldn’t increase the memory limit too high. It’s best to use as little memory as you can without degrading performance.

Remember also that you can set the wp_max_memory_limit parameter to affect only the back end, which is often where memory exhausted errors crop up.

With that said, a small increase in the memory limit can fix a lot of errors on your site.

Frequently Asked Questions

What is the recommended PHP memory limit in WordPress?

WordPress’ default memory limit is 40M for single-site and 64M for  multi-site. For many websites, 256M is reasonable with 512M being the upper limit for WordPress . Try to aim as low as possible to avoid using up unnecessary memory.

What is the maximum memory limit in WordPress?

There is no max memory limit in WordPress; this is limited only by how much memory/RAM your server has access to. However, going above 512M for the front end and 1024M for the back end is usually unnecessary.

How do you increase the memory limit in WordPress?

You can increase the memory limit in WordPress by editing the wp-config.php, php.ini, and .htaccess files.

What’s the difference between wp_memory_limit and wp_max_memory_limit?

wp_memory_limit sets the maximum amount of memory that can be allocated to WordPress in the front end (your public website). wp_max_memory_limit defines the memory limit for the WordPress admin dashboard and back end processes.

Is it safe to edit the PHP memory limit?

It’s generally safe to edit the PHP memory limit, but you should still be cautious. Always back up your website before editing sensitive configuration files, and avoid setting the memory limit too high, as it could lead to server instability and website crashes.

Posted inWordPress Management
Brenda Barron
Brenda Barron

Brenda is a freelance writer with over a decade of experience with web design, development, and WordPress. When not click-clacking at the keyboard, she’s spending time with her family, playing music, or taking up a new hobby.


Leave a Reply

Your email address will not be published. Required fields are marked *

Stay in the loop

Subscribe to the Melapress newsletter and receive curated WordPress management and security tips and content.

Newsletter icon

It’s free and you can unsubscribe whenever you want. Check our blog for a taste.

Envelope icon

The survey results are in: Find out what your WordPress security gameplan might be missing

Close

The survey results are in: Find out what your WordPress security gameplan might be missing

Uploading Melapress Login Security as a zip file in WordPress
Melapress Login Security in the WordPress plugin repository
Close

Installing Melapress Login Security Free

Congratulations on taking control of your WordPress website's security by implementing robust login and password policies with Melapress Login Security. You can change your login page URL, limit failed login attempts, and reset passwords.

 

Below are two ways to install Melapress Login Security on your website:

Go to your plugin dashboard on your site, then go to "Add New" and then search for Melapress Login Security.

Download the Melapress Login Security plugin zip, then select upload in your plugin dashboard under "Add New".

OPTION 1

OPTION 2

Uploading CAPTCHA 4WP as a zip file in WordPress
CAPTCHA 4WP in the WordPress plugin repository
Close

Installing CAPTCHA 4WP Free

Well done you. You're one step closer to safeguarding your WordPress website from spam and automated attacks with CAPTCHA 4WP. You'll be able to effortlessly integrate CAPTCHA into your forms and enjoy a website with enhanced security.

 

Below are two ways to install CAPTCHA 4WP on your website:

Go to your plugin dashboard on your site, then go to "Add New", and then search for CAPTCHA 4WP.

Download the CAPTCHA 4WP plugin zip, then select upload in your plugin dashboard under "Add New".

OPTION 1

OPTION 2

Uploading WP Activity Log as a zip file in WordPress
WP Activity Log in the WordPress plugin repository
Close

Installing WP Activity Log Free on your website

You deserve a pat on the back for choosing to record user actions and changes on your website. That is the first step towards better user accountability, easier troubleshooting of website security, and many other benefits of issues.

 

Below are the two ways to install WP Activity Log on your website:

Go to your plugin dashboard on your site, then go to "Add New" and then search for WP Activity Log.

Download the WP Activity Log plugin zip, then select upload in your plugin dashboard under "Add New".

OPTION 1

OPTION 2

Uploading WP 2FA as a zip file in WordPress
WP 2FA in the WordPress plugin repository
Close

Installing WP 2FA Free

Congratulations on taking the first step towards enhancing your WordPress site's security with WP 2FA Free! You're now on your way to protecting your valuable data and ensuring peace of mind. No coding or technical knowledge is required.

 

Below are two ways to install WP 2FA on your website:

Go to your plugin dashboard on your site, then go to "Add New", and then search for WP 2FA.

Download the WP 2FA plugin zip, then select upload in your plugin dashboard under "Add New".

OPTION 1

OPTION 2