Framework: PHP out of memory error when calling Artisan commands

Created on 27 Mar 2017  路  5Comments  路  Source: laravel/framework

  • Laravel Version: 5.4.15
  • PHP Version: 7.1.3

Description:

PHP is throwing the following error when trying to deploy with envoyer:

php artisan optimize
PHP Fatal error: Allowed memory size of 536870912 bytes exhausted (tried to allocate 262144 bytes) in /home/forge/project/releases/20170327091815/vendor/laravel/framework/src/Illuminate/Container/Container.php on line 621
PHP Fatal error: Allowed memory size of 536870912 bytes exhausted (tried to allocate 262144 bytes) in Unknown on line 0
Script php artisan optimize handling the post-install-cmd event returned with error code 255

Steps To Reproduce:

It fails on various commands and I can't replicate it reliably however it can sometimes be fixed by changing debug to true in the .env file.

Most helpful comment

@anewmanjones check your code for any recursive calls and update us :)

All 5 comments

AFAIK Laravel Framework dropping optimize command since 5.4.

Okay but the php artisan optimize command is still in composer.json scripts. I also get this error when calling other artisan commands such as "php artisan storage:link".

Check all your ServiceProviders. You might be calling $this->register where you're suppose to call $this->app->register() and, thus, causing infinite recursion.

@anewmanjones check your code for any recursive calls and update us :)

How can you fix this bug?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

gabriellimo picture gabriellimo  路  3Comments

felixsanz picture felixsanz  路  3Comments

digirew picture digirew  路  3Comments

shopblocks picture shopblocks  路  3Comments

YannPl picture YannPl  路  3Comments