Reputation: 1035
When deploying my Symfony2 project to my server I occassionally get the following error:
PHP Fatal error: Uncaught exception 'ErrorException' with message 'proc_open():
fork failed - Cannot allocate memory' in
in phar:///var/www/xyz.co.uk/releases/20130320161122/composer.phar/vendor/
symfony/console/Symfony/Component/Console/Application.php:982
Update
Full error message is below which occurs after --> Updating Composer dependencies
:
*** [err :: x.xx.xx.xxx] PHP Fatal error: Uncaught exception 'ErrorException' with message 'proc_open(): fork failed - Cannot allocate memory' in phar:///var/www/xyz.co.uk/releases/20130320161815/composer.phar/vendor/symfony/console/Symfony/Component/Console/Application.php:982
*** [err :: x.xx.xx.xxx] Stack trace:
*** [err :: x.xx.xx.xxx] #0 [internal function]: Composer\Util\ErrorHandler::handle(2, 'proc_open(): fo...', 'phar:///var/www...', 982, Array)
*** [err :: x.xx.xx.xxx] #1 phar:///var/www/xyz.co.uk/releases/20130320161815/composer.phar/vendor/symfony/console/Symfony/Component/Console/Application.php(982): proc_open('stty -a | grep ...', Array, NULL, NULL, NULL, Array)
*** [err :: x.xx.xx.xxx] #2 phar:///var/www/xyz.co.uk/releases/20130320161815/composer.phar/vendor/symfony/console/Symfony/Component/Console/Application.php(900): Symfony\Component\Console\Application->getSttyColumns()
*** [err :: x.xx.xx.xxx] #3 phar:///var/www/xyz.co.uk/releases/20130320161815/composer.phar/vendor/symfony/console/Symfony/Component/Console/Application.php(865): Symfony\Component\Console\ in phar:///var/www/xyz.co.uk/releases/20130320161815/composer.phar/vendor/symfony/console/Symfony/Component/Console/Application.php on line 982
*** [deploy:update_code] rolling back
failed: "sh -c 'sh -c '\\''cd /var/www/xyz.co.uk/releases/20130320161815 && php composer.phar update --no-scripts --verbose --prefer-dist'\\'''" on x.xx.xx.xxx
This doesn't happen ALL the time but just sometimes. I've allocated 256M in my apache and cli php.ini file on the server but still sometimes receive the error.
How much memory does Symfony require? Do I need to increase it further? I thought this would be enough.
Upvotes: 3
Views: 2829
Reputation: 8582
According to this post on GitHub: https://github.com/composer/composer/issues/945 It looks like you'll need at least 1GB of memory available to PHP.
Symfony is quite the memory hog and while 1Gb may sound ridiculous, for the type of processing it's performing it's most definitely not out of the question. If it's telling you you're out of memory, your only option is to add more memory.
You might also want to check back in a week or so and see if they haven't patched up some sort of memory leak as well.
Upvotes: 1
Reputation: 11102
Some symfony deployments needs a lot memory for update repositories. Also if you use capifony you could get a lot memory errors. The trick for deploy in small VPS or dedicated with less than 1-2 GB of RAM is create a SWAP where you will get store the memory need. So for example you can try creating 1 GB of swap with this commands:
# /bin/dd if=/dev/zero of=/var/swap.1 bs=1M count=1024
# /sbin/mkswap /var/swap.1
# /sbin/swapon /var/swap.1
Upvotes: 0
Reputation: 20201
Yes, Symfony
was always heavier than most frameworks out there but this error is kinda ridiculous. I'm saying this because my production machine has 512MB of RAM in total and 128M is allocated to PHP - and, still, application performs excellent.
Now, because complexity does play a major role here, where does you error occur? During the cache warm-up/clean? Are you trying to run some custom console command?
Also, have you tried installing APC? My application went blazing after doing that :)
Upvotes: 1