Raise the PHP memory ceiling first, then set WordPress limits inside wp-config.php. That is the safest rule. WP_MEMORY_LIMIT tells WordPress how much memory it may request, but PHP memory_limit is the server-level cap that decides whether that request can actually work. WordPress supports increasing allocated PHP memory through configuration, but hosting rules can still override it [source: WordPress Developer Resources].

TL;DR: If WordPress shows “Allowed memory size exhausted,” increase memory_limit at the PHP/server level and then set WP_MEMORY_LIMIT to a realistic value such as 256M. For example, a WooCommerce store with 42 active plugins may fail during product imports at 128M, but complete the same import after moving to 256M or 512M. Do not set huge values blindly; if memory use jumps 70% after installing one plugin, the plugin may be the real problem.

What WP_MEMORY_LIMIT Actually Does

WP_MEMORY_LIMIT is a WordPress constant usually added to wp-config.php. It tells WordPress the amount of memory it should try to use for normal front-end and back-end requests.

A typical setting looks like this:

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

Place it above this line:

/* That's all, stop editing! Happy publishing. */

This setting is useful when WordPress runs out of memory during common tasks, such as saving large pages, running page builders, importing content, processing forms, or loading the admin dashboard.

The catch is that WP_MEMORY_LIMIT is not magic. If your host blocks higher PHP memory values, WordPress can ask for 256M all day and still receive less. That is where many site owners waste time. They edit wp-config.php, reload the site, and the same fatal error appears 20 seconds later.

What PHP memory_limit Controls

memory_limit is a PHP configuration directive. It controls the maximum amount of memory a single PHP process may consume. Since WordPress runs on PHP, this setting affects every WordPress request.

You may find it in one of several places:

  • php.ini on VPS, dedicated, or managed servers.
  • .user.ini on many shared hosting accounts.
  • cPanel MultiPHP INI Editor or a similar hosting control panel.
  • Hosting dashboard settings on managed WordPress platforms.
  • .htaccess, but only on some Apache setups.

A server-level setting might look like this:

memory_limit = 256M

Or, in .htaccess, if supported:

php_value memory_limit 256M

Be careful with .htaccess. On many servers, adding unsupported PHP directives there will trigger a 500 error. Honestly, it feels like a trap because the file accepts the edit, then the site breaks with no friendly warning.

WP_MEMORY_LIMIT vs memory_limit: The Practical Difference

The difference is simple:

  • WP_MEMORY_LIMIT: WordPress-level request for normal site operations.
  • WP_MAX_MEMORY_LIMIT: WordPress-level request for heavier admin tasks.
  • memory_limit: PHP-level ceiling enforced by the server environment.

For heavy admin operations, WordPress may use WP_MAX_MEMORY_LIMIT. This applies to tasks such as image editing, updates, imports, and some admin screens.

You can set both WordPress constants like this:

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

A sensible setup for many business sites is:

  • Simple brochure site: 128M to 256M
  • Blog with several plugins: 256M
  • WooCommerce store: 256M to 512M
  • Large membership or LMS site: 512M or more, depending on traffic and plugins

Do not treat these as universal numbers. A clean site with 15 well-built plugins may use less memory than a bloated site with 6 poor plugins.

How to Check Your Current WordPress Memory Limit

Start with WordPress Site Health:

  1. Log in to WordPress.
  2. Go to Tools > Site Health.
  3. Open the Info tab.
  4. Expand the Server section.
  5. Look for PHP memory limit.

You can also create a temporary PHP info file, but only if you know what you are doing. Uploading a public phpinfo() file can expose server details. Delete it immediately after checking.

How to Increase WordPress Memory Limit Safely

Use this order. It reduces guesswork.

  1. Back up the site.

    Back up files and the database. Do not skip this on live sites.
  2. Increase PHP memory_limit.

    Use your hosting panel, php.ini, or .user.ini. Set it to 256M first unless your site clearly needs more.
  3. Add WordPress constants.

    Edit wp-config.php and add:

    define( 'WP_MEMORY_LIMIT', '256M' );
    define( 'WP_MAX_MEMORY_LIMIT', '512M' );
  4. Clear all caches.

    Clear page cache, object cache, CDN cache, and hosting cache if available.
  5. Retest the failed action.

    Repeat the import, update, checkout, image upload, or admin task that failed before.

If the value does not change in Site Health, your host may be enforcing a lower limit. In that case, editing WordPress files will not fix it. Ask the host to raise the account’s PHP memory limit or move the site to a plan with more resources.

Common Error Messages

Memory problems often appear as fatal errors. You may see messages like:

  • Fatal error: Allowed memory size of 134217728 bytes exhausted
  • There has been a critical error on this website
  • HTTP 500 error during updates or imports
  • White screen after activating a plugin

The number in bytes can help. For example, 134217728 bytes equals 128M. If that limit is being hit often, 256M may be a reasonable next step.

When Increasing Memory Is the Wrong Fix

More memory can hide bad code. It should not become a permanent bandage for every slow page or failed admin action.

Watch for these warning signs:

  • A single plugin causes memory use to spike after activation.
  • The admin dashboard takes 8 to 12 seconds longer than usual.
  • Imports fail only with one extension enabled.
  • Memory errors return even after moving from 256M to 512M.
  • Cron jobs run too often and overlap.

In those cases, audit plugins, themes, custom code, and database queries. Disable nonessential plugins on a staging site. Switch briefly to a default theme. Review PHP error logs. If object caching is available, consider Redis or Memcached on suitable hosting.

Recommended Configuration for Most Sites

For a serious WordPress site, a balanced configuration often looks like this:

// WordPress memory for normal requests
define( 'WP_MEMORY_LIMIT', '256M' );

// Higher memory for admin tasks
define( 'WP_MAX_MEMORY_LIMIT', '512M' );

Then match the PHP setting:

memory_limit = 512M

This gives WordPress room for admin tasks while keeping the setup controlled. If you are on shared hosting and cannot set 512M, use the highest stable value your host allows, then reduce plugin load.

Final Checklist

  • Set PHP memory_limit at or above the WordPress request.
  • Set WP_MEMORY_LIMIT for normal WordPress operations.
  • Set WP_MAX_MEMORY_LIMIT for heavier admin actions.
  • Verify the result in Site Health or server tools.
  • Investigate repeat failures instead of raising memory forever.

The best fix is controlled headroom. Give WordPress enough memory to run stable operations, but do not ignore the reason it needed more memory in the first place. A clean site with the right PHP limit, careful plugin choices, and realistic WordPress constants will be faster, safer, and easier to maintain.

You cannot copy content of this page