Skip to content

Increase WordPress Memory Limit

WordPress can occasionally run out of memory — usually on sites with heavy traffic, lots of features, or many plugins. It can also happen when a theme or plugin has problematic code.

When this occurs, you'll see an error like:

Allowed memory size of 19242411 bytes exhausted.

Sometimes the error includes the specific file or function that triggered it, which helps pinpoint a faulty plugin or theme. In other cases, your site simply needs more memory to function properly.

We recommend running your site on the latest supported PHP version, along with up-to-date WordPress core, themes, and plugins. This avoids many memory issues out of the box.

Step 1 — Check your current memory limits

WordPress 5.0+ includes a built-in Site Health tool. Open it via Tools → Site Health → Info in your WordPress dashboard.

There are two limits to be aware of:

LimitWhere it livesWhat it controls
Server PHP limitServer sectionThe maximum memory available to PHP on the server. WordPress can never exceed this value.
WordPress memory limitWordPress Constants sectionThe memory limit WordPress applies to itself (default 40M).
On shared hosting, the server PHP limit is fixed at 168 MB for all customers. On Managed VPS, we can customise the PHP settings for your server to meet your specific needs.

Step 2 — Understand the WordPress constants

Within the WordPress Constants section, you'll find two values:

  • WP_MEMORY_LIMIT — Memory limit for the front-end of your site. This is usually the value to raise when visitors are hitting fatal errors.
  • WP_MAX_MEMORY_LIMIT — Memory limit for the admin area. Can be set higher than WP_MEMORY_LIMIT since admin tasks (like page builders) often need more memory.

Step 3 — Increase the memory limits

To raise these limits, edit your wp-config.php file. You'll find it in your site's root directory, accessible via the File Manager or SFTP.

Look for these lines (or add them if they don't exist):

php
define( 'WP_MEMORY_LIMIT', '256M' );
define( 'WP_MAX_MEMORY_LIMIT', '512M' );
The values you set cannot exceed your server's PHP memory limit. If you set WP_MEMORY_LIMIT to 512M but your server limit is 168M, WordPress will be capped at 168M.

Save the file and refresh the Site Health page to confirm the new limits are active.