Tag Archive: swap

Composer update creates a lack of memory

While using Symfony 2 it’s common that you have to run the command composer update. Sometimes we’re graced with the error:

1
2
3
4
5
6
7
8
9
10
The following exception is caused by a lack of memory and not having swap configured

PHP Fatal error:  Uncaught exception 'ErrorException' with message 'proc_open(): fork failed - Cannot allocate memory' in phar:///usr/local/bin/composer/vendor/symfony/console/Application.php:954
Stack trace:
#0 [internal function]: Composer\Util\ErrorHandler::handle(2, 'proc_open(): fo...', 'phar:///usr/loc...', 954, Array)
#1 phar:///usr/local/bin/composer/vendor/symfony/console/Application.php(954): proc_open('stty -a | grep ...', Array, NULL, NULL, NULL, Array)
#2 phar:///usr/local/bin/composer/vendor/symfony/console/Application.php(754): Symfony\Component\Console\Application->getSttyColumns()
#3 phar:///usr/local/bin/composer/vendor/symfony/console/Application.php(715): Symfony\Component\Console\Application->getTerminalDimensions()
#4 phar:///usr/local/bin/composer/vendor/symfony/console/Application.php(648): Symfony\Component\Console\Application->getTerminalWidth()
#5 phar:///usr/local/bin/composer/vendor/symfony/console/Application.php(130): Symfony\Component\Console\Application->renderException(Object(ErrorException),  in phar:///usr/local/bin/composer/vendor/symfony/console/Application.php on line 954

The easiest way to fix it it’s by creating a virtual swap partition using the following commands:

1
2
3
/bin/dd if=/dev/zero of=/var/swap.1 bs=1M count=1024
/sbin/mkswap /var/swap.1
/sbin/swapon /var/swap.1