Troubleshooting
Memory limit errors in Composer and PHP
If, when running composer or a PHP task, you get errors such as:
- Check https://getcomposer.org/doc/articles/troubleshooting.md#memory-limit-errors for more info on how to handle out of memory errors
- PHP Fatal error: Allowed memory size of XXXXXX bytes exhausted
The fatal Allowed memory size ... exhausted confirms that the process reached memory_limit. First check the version, the command-line PHP and the effective value:
composer --version composer diagnose php --ini php -r 'echo ini_get("memory_limit"), PHP_EOL;'
For a single run, preferably raise the limit to a finite value compatible with your plan:
COMPOSER_MEMORY_LIMIT=2G composer install
php -d memory_limit=2G script.php
The one-off unlimited test documented by Composer must include the command in the same assignment:
COMPOSER_MEMORY_LIMIT=-1 composer install
Running just COMPOSER_MEMORY_LIMIT=-1 without export does not pass the value to the next process. -1 removes the limit of the Composer process, but not necessarily that of external processes; it does not increase RAM or avoid CloudLinux's PMEM or NPROC limits. If Killed appears, there is no PHP fatal error or the failure persists, check Resource Usage and its snapshots.
Before permanently changing Select PHP Version > Options > memory_limit, confirm with php --ini that the command-line PHP loads that configuration. Keep a finite value compatible with your plan's resources.
Install the intended dependencies
If the project includes composer.lock, composer install must respect those versions. Do not replace it with composer update to try to reduce memory: it would resolve a different set of dependencies. Use a maintained version of Composer compatible with the project and check which PHP binary its launcher actually runs.
The variable examples are for a Bash- or Zsh-compatible shell; PowerShell and CMD use a different syntax. Composer can run the project's plugins and scripts, so run the test on a trusted project and review its impact before repeating an installation in production. See the official Composer memory guide.
You may also find useful
- Composer installs a global package but cannot find its command Check that the global Composer binary exists, get its real directory and add it to PATH only when th...
- "An error occurred while sending the message" in the PrestaShop contact form Diagnose the contact form rejection and fix an old override only when it does not send contactform's...
- 404 errors on static files slow down browsing Detect missing static resources that trigger PHP and use CPU, serve them as lightweight 404s and gui...
- Debug errors in Joomla Get Joomla's exact error with its named reporting levels, without using numeric masks that depend on...
Something wrong or out of date? Tell us and we will review it.