Developer tool
PHP Memory Calculator
Reason about memory_limit sizing and interpret Allowed memory size exhausted messages.
How it works
What it does
The Memory Calculator helps you convert human sizes, compare candidate memory_limit values, and parse classic “Allowed memory size of … exhausted” messages into actionable numbers. It is a planning tool for workers, CLI imports, and FPM requests—not a profiler of your live heap.
When to use it
- A batch import dies halfway with a memory exhausted fatal
- You need to decide whether to raise limits or reduce peak usage
- Comparing CLI unlimited (
-1) habits vs FPM request caps
How input is processed safely
Inputs are sizes and error strings. Nothing is executed, no process memory is sampled on this host for your app, and no remote connection is opened. Results are arithmetic and parsing only.
Examples
- Parse an exhausted message showing 134217728 bytes → 128M
- Convert 512M to bytes for capacity worksheets
- Discuss why doubling memory without fixing leaks only delays failure
Common mistakes
- Setting huge FPM
memory_limitwithout considering workers × limit RAM blowups - Confusing peak allocation with average usage
- Raising limits instead of streaming large files or chunking DB reads
Memory fatals are often symptoms: unbounded array growth, loading entire files into strings, hydration of huge ORM graphs, or recursive rendering. Raising memory_limit can be correct for a legitimate batch job, but it is the wrong first move for a leaky request path shared by all FPM workers.
Because each FPM worker can approach the limit, total host RAM roughly tracks children × peak. Pair this calculator with the PHP-FPM pool calculator before you raise both knobs. CLI jobs can use higher limits or -1 more safely when they run sequentially.
When pasting an exhausted error, include the byte count line. Paths can be redacted; the numbers are what the parser needs.
Privacy note
Error messages may include file paths. Redact hostnames and internal paths if you paste logs from production.
Run in browser
AJAX processing only. No remote PHP execution sandbox. Results are not indexed.
Safety notes
- Submitted tool contents are not written to analytics or search logs.
- This site never evaluates arbitrary PHP from the browser.
- Generated configs are starting points—validate on a staging host before production.