STAGING

WordPress memory limit errors

An error such as "Allowed memory size of 134217728 bytes exhausted" means one page load needed more memory than PHP (the programming language WordPress runs on) is allowed to use. The number is in bytes; 134217728 bytes

The short answer

An error such as “Allowed memory size of 134217728 bytes exhausted” means one page load needed more memory than PHP (the programming language WordPress runs on) is allowed to use. The number is in bytes; 134217728 bytes is 128 MB.

Add define('WP_MEMORY_LIMIT', '256M'); to wp-config.php, raise memory_limit under PHP Settings in your hosting console, and reload. Then find out which plugin needed so much memory, because a higher limit is a bandage rather than a cure.

What it means

Each time a page is requested, PHP is given a fixed amount of working memory. The WordPress core, your theme and every active plugin share that allowance. If the total passes the limit, PHP stops at once and prints the error, which can appear on the page, in the admin area, during an upload, or show up as a white screen or critical error.

There are two limits involved. The server’s memory_limit is the hard ceiling, set in PHP’s own settings. Inside that, WordPress sets its own figure with WP_MEMORY_LIMIT (40M by default on the front end) and a higher one for admin tasks with WP_MAX_MEMORY_LIMIT (256M by default). WordPress can never raise itself above the server ceiling, so both may need attention.

The file path in the error message is the code that was running when memory ran out. It is often the victim rather than the culprit, since whichever plugin asked for the last bit of memory gets the blame.

Common causes

  • A heavy plugin or theme doing a big job. Page builders, image regeneration, large product imports and exports, e-commerce reports and backup plugins are the usual suspects.
  • Too many plugins active at once. Each one loads on every page, and fifty small ones add up.
  • Very large images. WordPress resizes each upload into several sizes in memory, and a 20 megapixel photo can push a modest limit over the edge.
  • A bug in a plugin that loops or keeps asking for memory until the limit is hit. Only an update or removal fixes this.
  • A limit set low on purpose. An old line in wp-config.php, or a php.ini or .user.ini file left behind by a previous host, can cap memory below what the server actually allows.

How to fix it

  1. Read the message. Note the number of bytes (divide by 1048576 to get megabytes) and the file path. If the path contains wp-content/plugins/some-plugin, that plugin was running at the time.
  2. Raise the WordPress limit. Over SFTP, or in File Manager in the management console (Plesk with WP Toolkit), edit wp-config.php. Above the line “That’s all, stop editing!” add define('WP_MEMORY_LIMIT', '256M');. For admin-only jobs such as imports you can also add define('WP_MAX_MEMORY_LIMIT', '512M');. If a WP_MEMORY_LIMIT line already exists, change it rather than adding a second one. This step is the same on every host.
  3. Raise the server limit. In the console go to Websites & Domains, open your domain and choose PHP Settings. Set memory_limit to 256M or higher and save. On other hosts this lives in php.ini or a .user.ini file in the site root.
  4. Confirm it took effect. Log in and go to Tools > Site Health > Info. Under Server you will see “PHP memory limit”, and under WordPress Constants the current WP_MEMORY_LIMIT. If the server figure did not change, look for a stray .user.ini or php.ini in the site root.
  5. Find the hungry plugin. If the error named a plugin, deactivate it under Plugins > Installed Plugins and test. If you cannot log in, rename its folder inside wp-content/plugins over SFTP. The free Query Monitor plugin shows peak memory per page and which plugin is responsible, and is worth installing temporarily.
  6. Move big jobs off the web. For large imports, image regeneration or bulk updates, use WP-CLI over SSH (for example wp media regenerate), which is not bound by the web request limits. If that is unfamiliar, ask support to run it for you.
  7. Shrink images before uploading and keep the plugin list lean. If normal pages need more than 256M, something is wrong with a plugin or theme, and raising the limit again only postpones the next error.

On WP Alpha

You can change the PHP version and memory_limit for your site yourself in the management console (Plesk with WP Toolkit). PHP 7.0 to 8.5 are available, and we recommend 8.3 or 8.4. VERIFY: the default and maximum memory_limit on each plan.

Redis object caching and page caching are on every plan, which means most visits are served without rebuilding the page in PHP at all, so memory-hungry pages are hit far less often. SSH, WP-CLI and real server cron are available for the heavy jobs that should not run inside a web request. If you want to test a higher limit or a plugin change without touching the live site, staging sites are one click in WP Toolkit.

If an error keeps coming back after you have raised the limit, support is 24/7 by live chat and tickets and can look at the logs with you.