When importing, thumbnail creation, page storage with a web developer, or a background job is stopped, the same PHP processing may have reached its memory ceiling. This is not the same as overflowing the entire server RAM:memory_limitApplies to each processing or request, while multiple workers can consume the total system RAM at the same time.
Quick answer:Read the permissible and the requested values from the fatal error message, specify the URL or job creator, and separate the PHP version of the web from the CLI. Limited and calculated increment can temporarily restore the service, but the unusual growth of data, loop or defective plugin must be remedied.
Common signs of PHP memory failure
- Message from the police.
Allowed memory size ... exhaustedIn the PHP log - 500 error only when importing, backuping or editing the main page
- The public page's success and the wp-admin or cron's failure
- Interrupting image processing or output file generation
- Restart worker next to memory log
The first fatal error is the same request from the computer that the computer made.WordPress log and PHPFind him.
Don't confuse four different numbers.
| Limitations and sources | Scope of effect | The point. |
|---|---|---|
memory_limit | PHP processing | It might be different between the web and the CLI. |
WP_MEMORY_LIMIT | Typical WordPress requests | It can't magically reject the host's forced ceiling. |
WP_MAX_MEMORY_LIMIT | Some management work. | The actual license is still dependent on PHP. |
| The container limit | The whole service or system. | Includes total workers and other services |
If PHP-FPM works with a ceiling of 256 MB and multiple workers, the potential capacity is not just a 256 MB number. Each worker does not necessarily consume up to a ceiling, but adjusting the number of workers regardless of RAM can create an OOM system.
Possible causes in practical order
- An extension or loop that creates a very large data or loop.
- Import/export, backup or processing of the image with an inappropriate batch.
- Page builder, query or response API with unusual volume.
- Change the PHP version or plugin and increase usage after the update.
- Lower adjustment to the actual workload.
- Difference between CLI, FPM and multi-pool or container settings.
- Too many workers and system-level memory pressure.
Stage by stage detection
- Record the time, endpoint, user and failed operation.
- Read the permissible, requested and file/line error messages.
- Check if an error occurred in the frontend, admin, cron, or WP-CLI.
- Specify the PHP version and the configuration file of the same SAPI.
- Check out the plugins in the stack trace and the latest changes.
- Reproduce the same scenario with controlled data in the staging.
- After each correction, measure the peak memory and the result of the operation again.
The file listed in the last line is not necessarily the primary culprit; it may just be where the last allocation was made. See stack trace, full input volume and call path.
Check the active PHP setting
Get out of here.php -iOr...php --iniIt is related to CLI and may differ from PHP-FPM. For a web environment, use Site Health, a protected identification page, or pool settings.phpinfo()Don't create; it reveals the details of the environment.
wp eval 'echo ini_get("memory_limit"), PHP_EOL;'
wp eval 'echo size_format( memory_get_peak_usage( true ) ), PHP_EOL;'
Run these commands at the right root of WordPress and with the right user. CLI execution does not reconstruct the actual web path, reverse proxy, and request; the result is just a complementary witness.
Low-risk to advanced solutions
1. Keep the operation small
In importing, image or row processing, reduce the batch and segment a very large file. Before deleting data or running the job again, make sure the operation is idempotent.
2. Isolate the recent changes
If the problem starts after the update, check the logs and the versions and the suspected add-ons in staging. For the decommissioned site, use the secure folder rename or WP-CLI method, but keep the status and rollback path;The error guide after the update.It's more detailed.
The roof is temporarily replaced.
Only when the workload is legitimate and RAM has capacity, set the value to the effective layer of the same environment. Managed hosts may be the reference panel or host support. Changing multiple files simultaneously makes it difficult to identify the source of the setting.
4 Modify the code or query used
Loading all records into memory, API response without pagination, oversized image and cache of large object should be improved in design. Use profiler and instrumentation on staging and don't just look at average consumption; peak is important.
How much memory is appropriate?
There is no universal number for all sites. Templates, plugins, image size, import and concurrency vary. The value should be as valid as the workload performance and calculated alongside the number of workers, RAM database, cache and secure edge of the system. A very high ceiling can hide the bug and, when traffic is in, several workers can overwhelm the entire server.
Common Mistakes
- Set it up.
-1Or a very large ceiling on production. - Assume that the CLI is the same as PHP-FPM.
- Increase worker and memory_limit at the same time
- Ignoring the file, line and request listed in fatal error
- Re-enforcing import or order without re-evaluating the effect
- Optimized plug-in to treat any type of memory leak
Prevention of the disease
Have the update and import test staged, batch large jobs, and monitor worker consumption, restart and OOM. For work on time, do not confuse timeout and memory: upgrading one does not necessarily solve the other.
When do you need special assistance?
If consumption grows again after a reasonable increase, occurs only in checkout or cron, or service with OOM is stopped, continuing testing on production is not appropriate.The technical troubleshooting service of WordPress.It can track user requests from PHP to plugins and server capacity.
Common Questions
Does the WP_MEMORY_LIMIT increase always work?
No, the host or PHP may impose a lower ceiling and the setting in context may be misread.
Is PHP memory short, or is it full server RAM?
Not necessarily. A request can reach its ceiling while the RAM is free; the reverse mode is also possible.
Why is it that only the preview is wrong?
Management, reporting, pagebuilding, or import tasks may process more data than publicly cached pages.