--- title: PHP Memory Limit description: "The RAM limit per PHP process. Raise it for a clear reason, not to hide a leak or a heavy plugin." canonical: https://penasihathosting.com/en/hosting-wiki/php-memory-limit type: wiki locale: en updated: 2026-10-29 author: Willya Randika --- # PHP Memory Limit ## Overview - **Summary:** The RAM limit per PHP process. Raise it for a clear reason, not to hide a leak or a heavy plugin. - **Author:** Willya Randika ([profile](/penulis/willya-randika)) ## Article `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](/en/hosting-wiki/php) and [PHP-FPM](/en/hosting-wiki/php-fpm) for server context. If the error appears as [Error 500](/en/hosting-wiki/error-500), check the log before changing configuration. ## FAQ Around 128 to 256 MB is usually enough. WooCommerce or heavy plugins may need 256 to 512 MB, but measure the real need. 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. PHP CLI and PHP-FPM read different configuration. Check each with `php -i` and `phpinfo()` on the web.