php artisan optimize command eat all ram space

Solution 1

Working try first command, not use second one

composer update --no-scripts
composer dump-autoload -o

Solution 2

Not trid yet

composer dumpautoload
composer update

Ref