Skip to main content

PHP Memory Limit

Updated: October 29, 2026
By Willya Randika

memory_limit is the maximum RAM one PHP process may use. If a script uses more, PHP stops with an error such as Fatal error: Allowed memory size of 134217728 bytes exhausted. The number 134217728 bytes means 128 MB.

Where the setting is read

The effective value comes from the global php.ini, the PHP-FPM pool configuration, .user.ini or .htaccess depending on SAPI, then ini_set() in the app if allowed. Because of that, phpinfo() or php -i | grep memory_limit is more accurate than guessing from a hosting dashboard.

In cPanel, open MultiPHP INI Editor, select the domain, and change memory_limit. On a PHP-FPM server, set php_admin_value[memory_limit] in the relevant pool, then restart FPM. The CLI value can differ. Check with php -r 'echo ini_get("memory_limit");'.

When raising it makes sense

Large imports, migrations, image or PDF generation, and CLI tools such as Composer or WP-CLI sometimes need more memory. Raise it in steps, for example 128 MB to 256 MB to 512 MB, while measuring.

Do not jump to -1 or unlimited. One bad script can consume server RAM and affect other accounts.

When not to raise it

If the error appears on an ordinary page with little content, a higher limit only delays the problem. Find the cause: a plugin loading an entire table, an unbounded loop, a very large image, or a missing cache.

On shared hosting, the provider sets the ceiling. If your needs consistently exceed the plan, moving to a VPS or larger plan makes more sense than forcing the limit.

Common mistakes

Editing the wrong php.ini is a common mistake because a server can have several PHP versions. Forgetting to restart PHP-FPM leaves pool changes inactive. Raising the limit without monitoring RAM can affect other accounts.

A memory error does not always mean the limit is too small. It may be a leak or oversized data. See PHP and PHP-FPM for server context. If the error appears as Error 500, check the log before changing configuration.

FAQ

What is a normal memory_limit for WordPress?

Around 128 to 256 MB is usually enough. WooCommerce or heavy plugins may need 256 to 512 MB, but measure the real need.

Does memory_limit affect the whole server?

No. It is a per-process PHP limit. However, if many workers use large amounts of RAM at once, total server memory can still run out.

Why is CLI different from the web?

PHP CLI and PHP-FPM read different configuration. Check each with php -i and phpinfo() on the web.

Disclaimer: Hosting Wiki articles are prepared for educational and reference purposes. Hosting technology keeps evolving, so some technical details may change over time.