How to Increase the PHP Memory Limit in WordPress

If you use WordPress, you may have at some point come across the annoying “memory exhausted” error message. When your PHP script needs more memory than is currently assigned to it, this error occurs. Fortunately, this problem can be fixed by increasing WordPress’ PHP memory limit.

In this tutorial, we will explain how to increase the PHP memory limit in WordPress, enabling the uninterrupted running of your website.

Why Increase the PHP Memory Limit in WordPress?

It is necessary to increase the PHP memory limit in WordPress for a few key reasons. Here’s why you should consider boosting your PHP memory:

1. Improved Performance: By increasing the PHP memory limit, you provide more resources for your WordPress website to operate efficiently. This is especially important if you have resource-intensive themes, plugins, or custom code that require additional memory to function properly.

2. Avoiding Memory Exhaustion Errors: If your website exceeds the default PHP memory limit, you may encounter “memory exhausted” or “fatal error: allowed memory size” messages. These errors can cause your site to crash or become unresponsive. Increasing the PHP memory limit helps prevent these issues and ensures smooth operation.

3. Handling Large Files and Processes: If you often work with large files, run complex queries, or execute data-intensive operations on your WordPress site (e.g., importing/exporting data), having sufficient PHP memory is crucial. Insufficient memory can lead to incomplete tasks or even the corruption of data.

4. Compatibility with Resource-Intensive Plugins and Themes: Certain plugins and themes function optimally with higher amounts of PHP memory. If you’re using such resource-intensive tools on your WordPress site, it’s essential to increase the memory limit to ensure their proper functioning.

You may like: How to Improve Crawlability and Indexability of Your Website

How Can You Increase WP Memory Limit?

The WP_MEMORY_LIMIT option allows you to specify the maximum amount of memory that can be consumed by PHP. This setting may be necessary in the event you receive a message such as “Allowed memory size of xxxxxx bytes exhausted”.

This setting increases PHP Memory only for WordPress, not other applications. By default, WordPress will attempt to increase the memory allocated to PHP to 40MB (code is at the beginning of /wp-includes/default-constants.php) for the single site and 64MB for multisite, so the setting in wp-config.php should reflect something higher than 40MB or 64MB depending on your setup.

WordPress will automatically check if PHP has been allocated less memory than the entered value before utilising this function. For example, if PHP has been allocated 64MB, there is no need to set this value to 64M as WordPress will automatically use all 64MB if need be.

Please note, this setting may not work if your host does not allow for increasing the PHP memory limit; in that event, contact your host to increase the PHP memory limit. Also, note that many hosts set the PHP limit at 8MB.

Increase PHP Memory to 64MB

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

Increase PHP Memory to 96MB

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

Administration tasks require more memory than usual operation. When in the administration area, the memory can be increased or decreased from the WP_MEMORY_LIMIT by defining WP_MAX_MEMORY_LIMIT.

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

Please note, this has to be put before wp-settings.php inclusion.


Increasing the PHP memory limit in WordPress allows you to harness the full potential of your website by ensuring optimal performance, stability, and compatibility with resource-intensive components like plugins and themes. It provides a solid foundation for managing larger files, executing complex processes efficiently, and preventing potentially disruptive errors related to insufficient memory allocation.

I hope this post helps you fix problems on your website arising from the limited memory limit set by your web host. You can reach out to us for professional help if you are unable to increase the memory on your own.

Show More

Raj Maurya

Raj Maurya is the founder of Digital Gyan. He is a technical content writer on Fiverr and freelancer.com. When not working, he plays Valorant.

Leave a Reply

Back to top button