How to Increase WP Memory Limit: WP_MEMORY_LIMIT vs PHP memory_limit for Managing WordPress Resources

Raise PHP memory_limit first, then set WordPress WP_MEMORY_LIMIT inside that ceiling. WordPress can request more memory, but PHP still controls the hard per-process limit. If PHP allows only 128M, setting WordPress to 256M will not reliably help. WordPress documents its default memory limit as 40M for a single site and 64M for multisite, which is often too low for page builders, WooCommerce, large imports, and image processing [source: WordPress].

TL;DR: Set PHP memory_limit to a safe upper cap, such as 256M or 512M, then set WP_MEMORY_LIMIT to a value at or below that cap. For example, if a WooCommerce store fails during a 2,000-product CSV import at 128M, raising PHP to 512M and WordPress to 256M may stop fatal memory errors without giving every request unlimited space. If 4 out of 10 admin tasks fail with “Allowed memory size exhausted,” memory is a likely suspect, but plugin bloat or bad code may still be the real problem.

WP_MEMORY_LIMIT vs PHP memory_limit

PHP memory_limit is the maximum amount of memory one PHP process can use. It is set at the server or hosting level. You may edit it through php.ini, .user.ini, hosting control panel settings, or a PHP-FPM pool config.

WP_MEMORY_LIMIT is a WordPress constant. It tells WordPress how much memory it should try to use for normal requests. It is usually defined in wp-config.php. WordPress can ask PHP for more memory, but it cannot force the server to allow it.

The short version is simple:

  • PHP memory_limit is the server-side ceiling.
  • WP_MEMORY_LIMIT is WordPress asking to use memory within that ceiling.
  • WP_MAX_MEMORY_LIMIT is used for heavier admin tasks, such as updates and image handling.

Honestly, it feels like this should be clearer in most hosting dashboards. You change one value, reload the site, and the fatal error still appears. Then you learn there was a second memory setting sitting above it the whole time.

There is no perfect number for every site. A small blog does not need the same headroom as a subscription store with 50 active plugins.

Use these as practical starting points:

  • Small blog or brochure site: 128M PHP, 128M WordPress.
  • Business site with several plugins: 256M PHP, 256M WordPress.
  • WooCommerce, LMS, membership, or builder-heavy site: 512M PHP, 256M or 512M WordPress.
  • Large imports or media-heavy work: temporary 512M or more, if your hosting plan supports it.

Do not set memory to -1 unless you know exactly why. That disables the PHP memory limit. It may hide a broken plugin until the server becomes slow or unstable.

How to increase WP_MEMORY_LIMIT

Edit the wp-config.php file in the root folder of your WordPress installation. Add the line before the comment that says “That’s all, stop editing!”.

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

For admin screens and heavier backend jobs, you can also add:

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

This setup tells WordPress to use up to 256M for normal requests and up to 512M for demanding admin operations. That can help when image uploads, plugin updates, backups, or imports fail.

Keep the numbers realistic. If your hosting account only allows PHP to use 256M, then WP_MAX_MEMORY_LIMIT set to 512M will not work as expected.

How to increase PHP memory_limit

The right method depends on your server type and hosting provider.

  • cPanel: open MultiPHP INI Editor or Select PHP Version, then change memory_limit.
  • php.ini: add or edit memory_limit = 512M.
  • .user.ini: add memory_limit = 512M. This is common on PHP-FPM hosting.
  • .htaccess: use php_value memory_limit 512M, but only if your server supports it.
  • Managed hosting: use the hosting dashboard or ask support to raise the limit.

Example:

memory_limit = 512M

If using .user.ini, wait a few minutes. Some servers cache these values. That delay is annoying when you are testing a fix under pressure, but it is normal.

How to check the active memory limit

Do not assume the change worked. Verify it.

  • Go to Tools > Site Health > Info > Server in WordPress.
  • Look for PHP memory limit.
  • Use a plugin health report if your host hides server values.
  • Create a temporary phpinfo() file only if you know how to remove it after testing.

You can also ask hosting support for the active PHP limit. Ask specifically: “What is the effective PHP memory_limit for this site?” That wording matters. A sales page may advertise one value while your actual account uses another.

Common errors caused by low memory

Low memory often appears as a fatal error. The message usually looks like this:

Fatal error: Allowed memory size of 134217728 bytes exhausted

That number is bytes. For example, 134217728 bytes is about 128M. If the error appears during checkout, import, backup, translation scanning, or image resizing, memory may be too low.

Still, raising memory should not be your only fix. A site that needs 1G for normal page loads likely has another issue. Possible causes include:

  • Too many active plugins.
  • A plugin with inefficient queries.
  • Large autoloaded options in the database.
  • Heavy page builder templates.
  • Oversized images being processed at upload.
  • Backup jobs running during peak traffic.

Best practice for WordPress resource management

A sensible setup uses enough memory to prevent failures, but not so much that bad code goes unnoticed. Start with 256M for most WordPress business sites. Move to 512M for WooCommerce, LMS, or large admin jobs.

Then reduce waste:

  • Remove unused plugins instead of only deactivating them.
  • Use object caching if your host supports Redis or Memcached.
  • Optimize images before upload.
  • Schedule backups during low-traffic hours.
  • Test imports on staging before running them on production.
  • Update PHP to a supported version for better performance and security.

Safe setup example

For a typical WooCommerce store, a balanced configuration may look like this:

// wp-config.php
define( 'WP_MEMORY_LIMIT', '256M' );
define( 'WP_MAX_MEMORY_LIMIT', '512M' );
; php.ini or .user.ini
memory_limit = 512M

This gives WordPress enough working room while keeping PHP capped. It also lets admin tasks use more memory than public page views. That is useful because customers browsing products should not need as much memory as a bulk product import.

Final recommendation

Set PHP memory_limit as the top boundary, then set WP_MEMORY_LIMIT inside it. For most modern WordPress sites, 256M is a fair baseline. For WooCommerce or heavy admin work, use 512M at the PHP level and set WP_MAX_MEMORY_LIMIT to match if your host allows it.

If memory errors continue after that, stop raising numbers and audit the site. Memory limits fix capacity problems. They do not fix bloated plugins, poor queries, or oversized background jobs.

You May Also Like