PHP Memory Limit: Setting a Sane Limit

2 min read

Overview #

memory_limit controls how much RAM a single PHP request may use. Two alerts relate to it: an unlimited limit (-1) and a memory peak above 85% of the configured limit. Both are fixable and usually point at a specific plugin or operation.

The Alerts #

Alert Meaning
Unlimited PHP memory_limit (warning) Set to -1: a single runaway script can exhaust server RAM with no guardrail
High PHP Memory Peak (warning) Usage exceeded 85% of the limit: the site is running too close to the ceiling

Why Unlimited Is a Problem #

-1 sounds generous but removes the safety brake:

  • No guardrail: a memory leak or infinite loop consumes RAM until the server (or neighbours on shared infrastructure) suffers
  • Hides bloat: poorly written plugins never surface their memory usage until it’s critical
  • Unpredictable failures: instead of a clean error, you get crashes and downtime

Setting a Sane Limit #

256MB is the sensible default for most WordPress sites. Raise it deliberately for known-heavy tasks (migrations, media processing, large imports) rather than removing the limit.

  • GridPane: control panel → PHP settings (Xponent does this for you)
  • php.ini / .user.ini: memory_limit = 256M
  • wp-config.php (last resort): define('WP_MEMORY_LIMIT', '256M'); (note this only affects WordPress, not other PHP scripts)

Diagnosing a High Peak (>85%) #

When usage spikes above 85%:

  1. Identify the trigger: was something specific happening? (import, report, media upload, heavy page)
  2. Check the logs: PHP error logs show which plugin/process consumed memory
  3. Common culprits: analytics plugins, page-builder-heavy pages, bulk operations, unoptimized queries
  4. Apply the right fix: plugin update/replacement, query optimization, cache tuning, or a deliberate limit adjustment

What You Should Do #

Nothing: this is a configuration fix on our side. If you were doing something specific when a peak happened, tell us; it speeds up the diagnosis considerably.

Related Articles #

Updated on August 31, 2026