The fatal message includes the allowed bytes, attempted allocation, file, and line. The last file is not always the root cause; it may simply be where an already-large request asked for one more block.
Use the sequence below as a diagnostic method, not as a promise that one setting fits every host; verify its example paths, privileges, and backup assumptions while working to read the fatal error, identify the operation allocating memory, and decide whether the limit or the workload is wrong.
Likely failure paths
- A plugin loads a large dataset or builds an unbounded object graph.
- Image processing, imports, backups, or page builders legitimately need more memory than ordinary requests.
- Too many plugins and autoloaded options consume a large baseline before useful work begins.
The branches are ordered to protect the strongest evidence around this possibility: a plugin loads a large dataset or builds an unbounded object graph. The observed scope and logs—not a familiar-looking error screen—decide which one applies.
Runtime incidents cross several boundaries: the browser reports an HTTP result, the web server hands work to PHP, and WordPress then loads core, plugins, the theme, and data; evidence from the earliest failing boundary is more useful than the component visible on screen; in this guide, the practical goal is to read the fatal error, identify the operation allocating memory, and decide whether the limit or the workload is wrong.
A controlled investigation
- Record the full fatal message and the action that triggered it.
- Compare PHP
memory_limit, WordPressWP_MEMORY_LIMIT, andWP_MAX_MEMORY_LIMIT; the effective ceiling may be controlled by the host. - Reproduce on staging with one suspected operation and inspect peak memory or Query Monitor data.
- Compare a normal page with the failing admin/import process.
The sequence moves from observation toward intervention. Preserve the result of the final check—compare a normal page with the failing admin/import process—because it provides a useful comparison after the repair.
Test one hypothesis without losing the baseline
The opening hypothesis is a plugin loads a large dataset or builds an unbounded object graph. Test it with the least invasive observation available: record the full fatal message and the action that triggered it. Do not change configuration until the observation has been saved with a timestamp.
When that evidence is consistent with the hypothesis, stage this repair: bound the query, batch size, image dimensions, or import chunk that causes the spike. Otherwise, preserve the current state and advance to the next branch. This keeps rollback simple and prevents a second change from masking the first.
Read the effective limits and WordPress ceilings
The PHP CLI and web SAPI can load different configuration. Use WP-CLI for the WordPress-side values, then confirm the hosting panel or a protected phpinfo page for the web request.
php -r 'echo "memory_limit=", ini_get("memory_limit"), PHP_EOL;'
wp eval 'echo "WP_MEMORY_LIMIT=", WP_MEMORY_LIMIT, PHP_EOL;'
wp eval 'echo "WP_MAX_MEMORY_LIMIT=", WP_MAX_MEMORY_LIMIT, PHP_EOL;'
Interpretation and safety: A higher ceiling is justified only after the failing operation and peak usage are known. Do not set memory_limit to -1 on a public site.
Make the smallest durable change
- Bound the query, batch size, image dimensions, or import chunk that causes the spike.
- Remove unnecessary autoloaded data or a plugin that consumes memory on every request.
- Raise the effective limit only when the workload is legitimate and the server has physical headroom.
Before applying “Bound the query, batch size, image dimensions, or import chunk that causes the spike,” name its rollback point and the evidence that will count as success. Afterward, repeat the original request and specifically check whether you can repeat the original operation with the same input; a changed symptom at that point is new evidence, not permission to make several more changes at once.
Close the incident with evidence
- Repeat the original operation with the same input.
- Confirm peak memory stays comfortably below the ceiling rather than barely passing.
- Test concurrent requests so one successful process does not exhaust the server under load.
One successful refresh is not closure. Keep the incident open until you can also confirm peak memory stays comfortably below the ceiling rather than barely passing, adjacent paths have not regressed, temporary diagnostics are gone, and another operator can explain what changed.
Prepare a useful escalation if the boundary is outside your control
A hosting escalation should include the UTC timestamp, affected URL, response status, request or trace ID when available, PHP version, WordPress version, and the first relevant log entry; redact cookies, passwords, tokens, database credentials, and personal data; include the result of this first observation: record the full fatal message and the action that triggered it.
State what was tested, including the result of “Record the full fatal message and the action that triggered it,” and what changed between attempts; evidence tied to that observation is safer and more actionable than granting broad access or sending an unnecessary full database export.
Do not trade visibility for a green screen
- Do not set memory_limit to -1 on a public site.
- Do not assume the file named at the fatal line created all allocated memory.
Operator record
Primary references
- WordPress PHP optimization — official reference consulted for this guide.
- PHP core directives — official reference consulted for this guide.
Editorial note: The scenario above illustrates how to approach “Bound the query, batch size, image dimensions, or import chunk that causes the spike”; it is a documented example, not a claim about a reader’s server, so verify the cited documentation, take the appropriate backup, and follow the real environment’s access and change-control rules.