How to increase the WordPress memory limit

WordPress memory limit

The WordPress Memory Limit is the maximum memory that WordPress can use to execute scripts and handle requests.

TL;DR

To increase the WordPress memory limit, you must add the following line of code in your wp-config.php file:

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

Replace 256M with your desired value.

What is the WordPress memory limit?

WordPress memory limit is not the same as PHP memory limit.

PHP memory limit is the maximum memory a PHP script can use during its execution. This limit is set in php.ini and controls how much memory any PHP script running on the server can consume, including WordPress.

WordPress memory limit is a WordPress-specific setting that defines how much memory the platform can use within the server’s PHP memory limit.

So, think of WordPress memory limit as a subset of PHP memory limit.

This limit is defined within WordPress but is ultimately controlled by the PHP memory limit set in the server’s php.ini file. If WordPress tries to allocate more memory than PHP allows, it will still be restricted by the server settings.

By default, WordPress allocates:

  • 40 MB for front-end operations
  • 256 MB (or the memory_limit set in php.ini value if this is higher) for wp-admin operations

If a website runs complex plugins, complex queries, or other memory-intensive operations, increasing the WordPress memory limit can help prevent errors such as “Allowed memory size exhausted” and improve overall performance.

If your WordPress site encounters errors due to low memory, increasing the memory limit can resolve them.

How to check your WordPress memory limit

You can check your WordPress memory limit using the WordPress Site Health Tool.

WordPress has a built-in tool that displays your current memory limit:

  • Go to Tools > Site Health in your WordPress dashboard.
  • Click on the Info tab and expand the WordPress Constants section.
  • Look for the WP_MEMORY_LIMIT and the WP_MAX_MEMORY_LIMIT – these show the maximum memory available to WordPress (frontend and backend).
WordPress Constants

In the image above, the WordPress memory limit for the frontend operations is the default 40 MB, and the WordPress memory limit for the backend (wp-admin) is 512 MB because the server’s PHP memory limit (set in php.ini) is 512 MB and that value is higher than the 256 MB that is the WordPress default for the backend.

How to increase the WordPress memory limit

If your WordPress site runs out of memory, and you get errors like “Fatal error: Allowed memory size of xxxxx bytes exhausted.” or “Fatal error: Out of memory.” you can increase the WordPress memory limit by modifying the wp-config.php file.

This is the easiest way to define a higher memory limit in WordPress itself, and it doesn’t require any advanced technical expertise on your part.

Copy the following code snippet

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

Find your wp-config.php file

File Manager

The wp-config.php file is usually located in the root folder of your website, where WordPress is installed. Depending on your hosting provider, it may be one folder above. At Simplenet, it’s in the public_html folder.

You can access the files using the File Manager feature in the Simplenet control panel or connect to your server via FTP with a client like FileZilla. The easiest way is to use the File Manager, so follow these steps:

  • Log in to the Simplenet hosting control panel with your email and password
  • Click on your website
  • Go to Files
  • Click on the public_html folder
  • Double-click on wp-config.php to open the file

Add the code to the wp-config.php file

The wp-config.php file

In the wp-config.php file, locate this line:

/* Add any custom values between this line and the "stop editing" line. */

Paste the copied code below the line.

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

Replace 256M with your desired value.

Save changes

The final step is to click Save. Close the file editor. You have now increased your WordPress memory limit.

A quick note on PHP memory limit

Remember that the default PHP memory limit on the Simplenet servers is 512 MB, so if you want to add a value higher than 512 MB for the WordPress memory limit, it will not work.

Regardless of what value you add in the wp-config.php file, the server’s PHP memory limit will contain the WordPress memory limit to 512 MB.

To change the PHP memory limit to a higher value, access your control panel, go to Advance > Developer Tools, scroll down to php.ini editor, double-click on memory_limit, and set a new value, like 1024M.

PHP memory limit

We actively monitor our servers to ensure stability and performance for all clients. When adjusting your memory limit, we recommend setting a value that fits your site’s needs rather than arbitrarily increasing it. If you’re unsure, feel free to contact us—we’re happy to help you find the right balance.

If you get memory exhaustion errors, it’s best to collaborate to find out what is causing the resource usage rather than increasing the memory limit to very high values, which might do more harm than good.

We’re here to help, so don’t hesitate to contact our support team.

Elena Chira Avatar

Comments

Leave a Reply

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