Search code examples
phpmemorysymfonyfatal-errorcapifony

PHP Fatal error when deploying Symfony2 project using Capifony


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.


Solution

  • 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 :)