New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ErrorException: proc_open(): fork failed - Cannot allocate memory in phar #945

Closed
yooper opened this Issue Jul 26, 2012 · 77 comments

Comments

Projects
None yet
@yooper

yooper commented Jul 26, 2012

ErrorException: proc_open(): fork failed - Cannot allocate memory in phar:///var/www/workspace/MyProject/build/composer/composer.phar/vendor/symfony/console/Symfony/Component/Console/Application.php on line 943

Call Stack:
0.0523 765208 1. {main}() /var/www/workspace/MyProject/build/composer/composer.phar:0
0.0528 763216 2. require('phar:///var/www/workspace/MyProject/build/composer/composer.phar/bin/composer') /var/www/workspace/MyProject/build/composer/composer.phar:15
0.0830 3504584 3. Composer\Console\Application->run() phar:///var/www/workspace/MyProject/build/composer/composer.phar/bin/composer:13
0.0865 3865984 4. Symfony\Component\Console\Application->run() phar:///var/www/workspace/MyProject/build/composer/composer.phar/src/Composer/Console/Application.php:66
31.9725 246198552 5. Symfony\Component\Console\Application->renderException() phar:///var/www/workspace/MyProject/build/composer/composer.phar/vendor/symfony/console/Symfony/Component/Console/Application.php:113
31.9726 246199624 6. Symfony\Component\Console\Application->getTerminalWidth() phar:///var/www/workspace/MyProject/build/composer/composer.phar/vendor/symfony/console/Symfony/Component/Console/Application.php:771
31.9726 246199784 7. Symfony\Component\Console\Application->getSttyColumns() phar:///var/www/workspace/MyProject/build/composer/composer.phar/vendor/symfony/console/Symfony/Component/Console/Application.php:848
31.9727 246202984 8. proc_open() phar:///var/www/workspace/MyProject/build/composer/composer.phar/vendor/symfony/console/Symfony/Component/Console/Application.php:943
31.9728 246204736 9. Composer\Util\ErrorHandler::handle() phar:///var/www/workspace/MyProject/build/composer/composer.phar/src/Composer/Util/ErrorHandler.php:0

@yooper

This comment has been minimized.

Show comment
Hide comment
@yooper

yooper Jul 26, 2012

In order to resolve this issue I had to make sure there was over 1 gig of memory available.

yooper commented Jul 26, 2012

In order to resolve this issue I had to make sure there was over 1 gig of memory available.

@fixe

This comment has been minimized.

Show comment
Hide comment
@fixe

fixe Aug 1, 2012

Contributor

I was also having this issue but increasing the PHP memory_limit solved the problem.

Contributor

fixe commented Aug 1, 2012

I was also having this issue but increasing the PHP memory_limit solved the problem.

@raulfraile

This comment has been minimized.

Show comment
Hide comment
@raulfraile

raulfraile Aug 2, 2012

Same here:

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

Fatal error: Uncaught exception 'ErrorException' with message 'proc_open(): fork failed - Cannot allocate memory' in phar:///usr/local/bin/composer/vendor/symfony/console/Symfony/Component/Console/Application.php on line 943

ErrorException: proc_open(): fork failed - Cannot allocate memory in phar:///usr/local/bin/composer/vendor/symfony/console/Symfony/Component/Console/Application.php on line 943

Call Stack:
    0.0001     620632   1. {main}() /usr/local/bin/composer:0
    0.0032     727952   2. require('phar:///usr/local/bin/composer/bin/composer') /usr/local/bin/composer:15
    0.0187    3168240   3. Composer\Console\Application->run() phar:///usr/local/bin/composer/bin/composer:13
    0.0211    3485008   4. Symfony\Component\Console\Application->run() phar:///usr/local/bin/composer/src/Composer/Console/Application.php:66
   13.2099  135622120   5. Symfony\Component\Console\Application->renderException() phar:///usr/local/bin/composer/vendor/symfony/console/Symfony/Component/Console/Application.php:113
   13.2099  135622968   6. Symfony\Component\Console\Application->getTerminalWidth() phar:///usr/local/bin/composer/vendor/symfony/console/Symfony/Component/Console/Application.php:771
   13.2099  135623064   7. Symfony\Component\Console\Application->getSttyColumns() phar:///usr/local/bin/composer/vendor/symfony/console/Symfony/Component/Console/Application.php:848
   13.2099  135625208   8. proc_open() phar:///usr/local/bin/composer/vendor/symfony/console/Symfony/Component/Console/Application.php:943
   13.2100  135626416   9. Composer\Util\ErrorHandler::handle() phar:///usr/local/bin/composer/vendor/symfony/console/Symfony/Component/Console/Application.php:943

More info about the system:

php -v
PHP 5.3.10 (cli) (built: Feb 20 2012 16:56:36) 
Copyright (c) 1997-2012 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2012 Zend Technologies
    with Xdebug v2.2.1, Copyright (c) 2002-2012, by Derick Rethans

Same here:

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

Fatal error: Uncaught exception 'ErrorException' with message 'proc_open(): fork failed - Cannot allocate memory' in phar:///usr/local/bin/composer/vendor/symfony/console/Symfony/Component/Console/Application.php on line 943

ErrorException: proc_open(): fork failed - Cannot allocate memory in phar:///usr/local/bin/composer/vendor/symfony/console/Symfony/Component/Console/Application.php on line 943

Call Stack:
    0.0001     620632   1. {main}() /usr/local/bin/composer:0
    0.0032     727952   2. require('phar:///usr/local/bin/composer/bin/composer') /usr/local/bin/composer:15
    0.0187    3168240   3. Composer\Console\Application->run() phar:///usr/local/bin/composer/bin/composer:13
    0.0211    3485008   4. Symfony\Component\Console\Application->run() phar:///usr/local/bin/composer/src/Composer/Console/Application.php:66
   13.2099  135622120   5. Symfony\Component\Console\Application->renderException() phar:///usr/local/bin/composer/vendor/symfony/console/Symfony/Component/Console/Application.php:113
   13.2099  135622968   6. Symfony\Component\Console\Application->getTerminalWidth() phar:///usr/local/bin/composer/vendor/symfony/console/Symfony/Component/Console/Application.php:771
   13.2099  135623064   7. Symfony\Component\Console\Application->getSttyColumns() phar:///usr/local/bin/composer/vendor/symfony/console/Symfony/Component/Console/Application.php:848
   13.2099  135625208   8. proc_open() phar:///usr/local/bin/composer/vendor/symfony/console/Symfony/Component/Console/Application.php:943
   13.2100  135626416   9. Composer\Util\ErrorHandler::handle() phar:///usr/local/bin/composer/vendor/symfony/console/Symfony/Component/Console/Application.php:943

More info about the system:

php -v
PHP 5.3.10 (cli) (built: Feb 20 2012 16:56:36) 
Copyright (c) 1997-2012 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2012 Zend Technologies
    with Xdebug v2.2.1, Copyright (c) 2002-2012, by Derick Rethans
@KingCrunch

This comment has been minimized.

Show comment
Hide comment
@KingCrunch

KingCrunch Aug 13, 2012

Contributor

Got the same error two times, but can say: It work around an hour ago (without any change on the setup) and now in the third try it works again (without any change at all).

$ php -v
PHP 5.4.4-4~precise+1 (cli) (built: Aug  6 2012 13:01:46) 
Copyright (c) 1997-2012 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2012 Zend Technologies

Update:

OK, forget it. I forgot to enable the swap again... The machine really ran out of memory...

Contributor

KingCrunch commented Aug 13, 2012

Got the same error two times, but can say: It work around an hour ago (without any change on the setup) and now in the third try it works again (without any change at all).

$ php -v
PHP 5.4.4-4~precise+1 (cli) (built: Aug  6 2012 13:01:46) 
Copyright (c) 1997-2012 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2012 Zend Technologies

Update:

OK, forget it. I forgot to enable the swap again... The machine really ran out of memory...

@advancingu

This comment has been minimized.

Show comment
Hide comment
@advancingu

advancingu Sep 9, 2012

Had the same issue when trying to do a deployment to an Amazon AWS EC2 Micro instance. These instances have only 613MB of memory in total so composer fails to allocate enough memory for an update to run. Upgrading to a Small instance with 1.7GB of total memory got rid of the issue.

Had the same issue when trying to do a deployment to an Amazon AWS EC2 Micro instance. These instances have only 613MB of memory in total so composer fails to allocate enough memory for an update to run. Upgrading to a Small instance with 1.7GB of total memory got rid of the issue.

@Elijen

This comment has been minimized.

Show comment
Hide comment
@Elijen

Elijen Sep 13, 2012

I have the same issue .... does composer really need so much memory? :-O

Elijen commented Sep 13, 2012

I have the same issue .... does composer really need so much memory? :-O

@KingCrunch

This comment has been minimized.

Show comment
Hide comment
@KingCrunch

KingCrunch Sep 14, 2012

Contributor

I guess it's not composer itself, but anyway: The micro instances on ec2 doesn't have any swap memory (by default) and so the OS kicks the processes, if it runs out of memory. The better solution instead of upgrading to small (because it costs more) is to create a file based swap (at least temporary)

For example.

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

613M is very less and remember, that not only PHP consumes it. I don't think one can blame composer for it. Can somebody close this issue?

Contributor

KingCrunch commented Sep 14, 2012

I guess it's not composer itself, but anyway: The micro instances on ec2 doesn't have any swap memory (by default) and so the OS kicks the processes, if it runs out of memory. The better solution instead of upgrading to small (because it costs more) is to create a file based swap (at least temporary)

For example.

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

613M is very less and remember, that not only PHP consumes it. I don't think one can blame composer for it. Can somebody close this issue?

@Seldaek

This comment has been minimized.

Show comment
Hide comment
@Seldaek

Seldaek Sep 14, 2012

Member

People using micro instances should not have problems anymore after updating composer and updating your lock file to the new format, see #1109. If you have memory issues with other things than install, see #600.

Member

Seldaek commented Sep 14, 2012

People using micro instances should not have problems anymore after updating composer and updating your lock file to the new format, see #1109. If you have memory issues with other things than install, see #600.

@Seldaek Seldaek closed this Sep 14, 2012

@psliwa psliwa referenced this issue Sep 24, 2012

Closed

Error #22

@dhrrgn

This comment has been minimized.

Show comment
Hide comment
@dhrrgn

dhrrgn Dec 20, 2012

I am running into this issue again. Here is my Dump:

PHP Fatal error:  Uncaught exception 'ErrorException' with message 'proc_open(): fork failed - Cannot allocate memory' in phar:///vagrant/www/api-v3/composer.phar/vendor/symfony/console/Symfony/Component/Console/Application.php:969
Stack trace:
#0 [internal function]: Composer\Util\ErrorHandler::handle(2, 'proc_open(): fo...', 'phar:///vagrant...', 969, Array)
#1 phar:///vagrant/www/api-v3/composer.phar/vendor/symfony/console/Symfony/Component/Console/Application.php(969): proc_open('stty -a | grep ...', Array, NULL, NULL, NULL, Array)
#2 phar:///vagrant/www/api-v3/composer.phar/vendor/symfony/console/Symfony/Component/Console/Application.php(874): Symfony\Component\Console\Application->getSttyColumns()
#3 phar:///vagrant/www/api-v3/composer.phar/vendor/symfony/console/Symfony/Component/Console/Application.php(798): Symfony\Component\Console\Application->getTerminalWidth()
#4 phar:///vagrant/www/api-v3/composer.phar/vendor/symfony/console/Symfony/Component/Console/Application.php(113): Symfony\Component\Console\Application->re in phar:///vagrant/www/api-v3/composer.phar/vendor/symfony/console/Symfony/Component/Console/Application.php on line 969

Doing a Dry-Run with Profiling returns the following mem usage info:

Memory usage: 25.95MB (peak: 67.15MB), time: 9.21s

dhrrgn commented Dec 20, 2012

I am running into this issue again. Here is my Dump:

PHP Fatal error:  Uncaught exception 'ErrorException' with message 'proc_open(): fork failed - Cannot allocate memory' in phar:///vagrant/www/api-v3/composer.phar/vendor/symfony/console/Symfony/Component/Console/Application.php:969
Stack trace:
#0 [internal function]: Composer\Util\ErrorHandler::handle(2, 'proc_open(): fo...', 'phar:///vagrant...', 969, Array)
#1 phar:///vagrant/www/api-v3/composer.phar/vendor/symfony/console/Symfony/Component/Console/Application.php(969): proc_open('stty -a | grep ...', Array, NULL, NULL, NULL, Array)
#2 phar:///vagrant/www/api-v3/composer.phar/vendor/symfony/console/Symfony/Component/Console/Application.php(874): Symfony\Component\Console\Application->getSttyColumns()
#3 phar:///vagrant/www/api-v3/composer.phar/vendor/symfony/console/Symfony/Component/Console/Application.php(798): Symfony\Component\Console\Application->getTerminalWidth()
#4 phar:///vagrant/www/api-v3/composer.phar/vendor/symfony/console/Symfony/Component/Console/Application.php(113): Symfony\Component\Console\Application->re in phar:///vagrant/www/api-v3/composer.phar/vendor/symfony/console/Symfony/Component/Console/Application.php on line 969

Doing a Dry-Run with Profiling returns the following mem usage info:

Memory usage: 25.95MB (peak: 67.15MB), time: 9.21s
@KingCrunch

This comment has been minimized.

Show comment
Hide comment
@KingCrunch

KingCrunch Dec 20, 2012

Contributor

Hi,

Just a guess: Do you running this on a AWS-micro? Do you have a swap
enabled?

Regards,
Sebastian

2012/12/20 Dan Horrigan notifications@github.com

I am running into this issue again. Here is my Dump:

PHP Fatal error: Uncaught exception 'ErrorException' with message 'proc_open(): fork failed - Cannot allocate memory' in phar:///vagrant/www/api-v3/composer.phar/vendor/symfony/console/Symfony/Component/Console/Application.php:969
Stack trace:
#0 [internal function]: Composer\Util\ErrorHandler::handle(2, 'proc_open(): fo...', 'phar:///vagrant...', 969, Array)
#1 phar:///vagrant/www/api-v3/composer.phar/vendor/symfony/console/Symfony/Component/Console/Application.php(969): proc_open('stty -a | grep ...', Array, NULL, NULL, NULL, Array)
#2 phar:///vagrant/www/api-v3/composer.phar/vendor/symfony/console/Symfony/Component/Console/Application.php(874): Symfony\Component\Console\Application->getSttyColumns()
#3 phar:///vagrant/www/api-v3/composer.phar/vendor/symfony/console/Symfony/Component/Console/Application.php(798): Symfony\Component\Console\Application->getTerminalWidth()
#4 phar:///vagrant/www/api-v3/composer.phar/vendor/symfony/console/Symfony/Component/Console/Application.php(113): Symfony\Component\Console\Application->re in phar:///vagrant/www/api-v3/composer.phar/vendor/symfony/console/Symfony/Component/Console/Application.php on line 969

Doing a Dry-Run with Profiling returns the following mem usage info:

Memory usage: 25.95MB (peak: 67.15MB), time: 9.21s


Reply to this email directly or view it on GitHubhttps://github.com/composer/composer/issues/945#issuecomment-11587234.

github.com/KingCrunch

Contributor

KingCrunch commented Dec 20, 2012

Hi,

Just a guess: Do you running this on a AWS-micro? Do you have a swap
enabled?

Regards,
Sebastian

2012/12/20 Dan Horrigan notifications@github.com

I am running into this issue again. Here is my Dump:

PHP Fatal error: Uncaught exception 'ErrorException' with message 'proc_open(): fork failed - Cannot allocate memory' in phar:///vagrant/www/api-v3/composer.phar/vendor/symfony/console/Symfony/Component/Console/Application.php:969
Stack trace:
#0 [internal function]: Composer\Util\ErrorHandler::handle(2, 'proc_open(): fo...', 'phar:///vagrant...', 969, Array)
#1 phar:///vagrant/www/api-v3/composer.phar/vendor/symfony/console/Symfony/Component/Console/Application.php(969): proc_open('stty -a | grep ...', Array, NULL, NULL, NULL, Array)
#2 phar:///vagrant/www/api-v3/composer.phar/vendor/symfony/console/Symfony/Component/Console/Application.php(874): Symfony\Component\Console\Application->getSttyColumns()
#3 phar:///vagrant/www/api-v3/composer.phar/vendor/symfony/console/Symfony/Component/Console/Application.php(798): Symfony\Component\Console\Application->getTerminalWidth()
#4 phar:///vagrant/www/api-v3/composer.phar/vendor/symfony/console/Symfony/Component/Console/Application.php(113): Symfony\Component\Console\Application->re in phar:///vagrant/www/api-v3/composer.phar/vendor/symfony/console/Symfony/Component/Console/Application.php on line 969

Doing a Dry-Run with Profiling returns the following mem usage info:

Memory usage: 25.95MB (peak: 67.15MB), time: 9.21s


Reply to this email directly or view it on GitHubhttps://github.com/composer/composer/issues/945#issuecomment-11587234.

github.com/KingCrunch

@Seldaek

This comment has been minimized.

Show comment
Hide comment
@Seldaek

Seldaek Dec 20, 2012

Member

@dhorrigan ouch according to the stack trace it looks like the fatal error was triggered while rendering an exception (since that uses proc_open to check for your terminal width). Looks like it's not a php memory limit but rather the machine's memory that ran out, so I would suggest clearing other things, and running it with install instead of update if you can run update somewhere else that has more memory. install from lock file uses very little memory.

Member

Seldaek commented Dec 20, 2012

@dhorrigan ouch according to the stack trace it looks like the fatal error was triggered while rendering an exception (since that uses proc_open to check for your terminal width). Looks like it's not a php memory limit but rather the machine's memory that ran out, so I would suggest clearing other things, and running it with install instead of update if you can run update somewhere else that has more memory. install from lock file uses very little memory.

@dhrrgn

This comment has been minimized.

Show comment
Hide comment
@dhrrgn

dhrrgn Dec 20, 2012

I am running this in a Vagrant box, and there is quite a bit running on it, but this is the first time I have seen it. I will try re-building the box with more memory and see what happens. I will follow up.

dhrrgn commented Dec 20, 2012

I am running this in a Vagrant box, and there is quite a bit running on it, but this is the first time I have seen it. I will try re-building the box with more memory and see what happens. I will follow up.

@Seldaek

This comment has been minimized.

Show comment
Hide comment
@Seldaek

Seldaek Dec 20, 2012

Member

To be honest 67MB isn't so big. I can see how it's a problem if it fails, but in this day and age a couple hundred megs of peak memory isn't so much to ask for ;)

Member

Seldaek commented Dec 20, 2012

To be honest 67MB isn't so big. I can see how it's a problem if it fails, but in this day and age a couple hundred megs of peak memory isn't so much to ask for ;)

@dhrrgn

This comment has been minimized.

Show comment
Hide comment
@dhrrgn

dhrrgn Dec 20, 2012

Ya, found the problem, the VM only has 6MB of mem available (out of 512MB) so, ya. Haha, I am upping it to have 1GB of memory. Should have checked that first. Carry on.

dhrrgn commented Dec 20, 2012

Ya, found the problem, the VM only has 6MB of mem available (out of 512MB) so, ya. Haha, I am upping it to have 1GB of memory. Should have checked that first. Carry on.

@KingCrunch

This comment has been minimized.

Show comment
Hide comment
@KingCrunch

KingCrunch Dec 20, 2012

Contributor

@Seldaek The micro instances have 590MB and by default no swap. For playing around this works fine, but as soon as some application needs a little bit more it completely breaks. So as mentioned earlier: Creating a swap catches this :) It only takes 10, or 20 MB more.

#945 (comment)

Contributor

KingCrunch commented Dec 20, 2012

@Seldaek The micro instances have 590MB and by default no swap. For playing around this works fine, but as soon as some application needs a little bit more it completely breaks. So as mentioned earlier: Creating a swap catches this :) It only takes 10, or 20 MB more.

#945 (comment)

@andremaha

This comment has been minimized.

Show comment
Hide comment
@andremaha

andremaha Jan 22, 2013

@KingCrung is right. Just added swap to my EC2 micro instance as described here.

Now updating dependencies works like a charm.

@KingCrung is right. Just added swap to my EC2 micro instance as described here.

Now updating dependencies works like a charm.

@ghost

This comment has been minimized.

Show comment
Hide comment
@ghost

ghost Feb 15, 2013

@andremaha Perfect! Thank you!! :)

ghost commented Feb 15, 2013

@andremaha Perfect! Thank you!! :)

@jmoz

This comment has been minimized.

Show comment
Hide comment
@jmoz

jmoz Apr 9, 2013

I'm also getting this problem. 1GB Vagrant on a 4GB Macbook Air. Happens even when I'm limiting an update to a specific vendor.

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

Can solve it by vagrant halt && vagrant up && vagrant ssh, then running again.

Memory usage: 102.39MB (peak: 427.97MB), time: 104.79s

jmoz commented Apr 9, 2013

I'm also getting this problem. 1GB Vagrant on a 4GB Macbook Air. Happens even when I'm limiting an update to a specific vendor.

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

Can solve it by vagrant halt && vagrant up && vagrant ssh, then running again.

Memory usage: 102.39MB (peak: 427.97MB), time: 104.79s

@williamn

This comment has been minimized.

Show comment
Hide comment
@williamn

williamn Oct 17, 2013

@adamsmeat thanks! I use your solution for my DO instance

@adamsmeat thanks! I use your solution for my DO instance

@hppycoder

This comment has been minimized.

Show comment
Hide comment
@hppycoder

hppycoder Nov 2, 2013

@adamsmeat - I can confirm on a stock loaded Ubuntu 12.04 512MB Digital Ocean machine that your solution is what was needed. Symfony2 is now installed and working as desired.

@adamsmeat - I can confirm on a stock loaded Ubuntu 12.04 512MB Digital Ocean machine that your solution is what was needed. Symfony2 is now installed and working as desired.

@rolies106

This comment has been minimized.

Show comment
Hide comment
@rolies106

rolies106 Dec 6, 2013

@adamsmeat that saved my life, just added 512MB swap space on my EC2 micro instance and the problem is solved.

@adamsmeat that saved my life, just added 512MB swap space on my EC2 micro instance and the problem is solved.

@Credochen

This comment has been minimized.

Show comment
Hide comment
@Credochen

Credochen Feb 6, 2014

我也遇到这样的问题,是使用vagrant box的环境,初始的内存为512M,增加到2048G后问题解决了。

我也遇到这样的问题,是使用vagrant box的环境,初始的内存为512M,增加到2048G后问题解决了。

@prodev42

This comment has been minimized.

Show comment
Hide comment
@prodev42

prodev42 Feb 8, 2014

encountered this problem using Digital Ocean 512MB slice...had to #945 (comment)

prodev42 commented Feb 8, 2014

encountered this problem using Digital Ocean 512MB slice...had to #945 (comment)

@allaniftrue

This comment has been minimized.

Show comment
Hide comment

same here @prodev42

@allaniftrue

This comment has been minimized.

Show comment
Hide comment
@allaniftrue

allaniftrue Feb 11, 2014

I tried copying composer.lock unto the live server and works. with the command

php composer.phar --verbose install

I tried copying composer.lock unto the live server and works. with the command

php composer.phar --verbose install

@KingCrunch

This comment has been minimized.

Show comment
Hide comment
@KingCrunch

KingCrunch Feb 12, 2014

Contributor

@paparts Sounds like you don't versionize the composer.lock? As a rule of thumb: For applications versionize it, for libraries, don't. You shouldn't run update on a live system, because it is quite likely, that sooner or later a package comes in, that breaks your application, without that you've tested it locally. The composer.lock and composer.phar install ensures, that exactly that packages in that versions are installed, that you've development your application against.

Contributor

KingCrunch commented Feb 12, 2014

@paparts Sounds like you don't versionize the composer.lock? As a rule of thumb: For applications versionize it, for libraries, don't. You shouldn't run update on a live system, because it is quite likely, that sooner or later a package comes in, that breaks your application, without that you've tested it locally. The composer.lock and composer.phar install ensures, that exactly that packages in that versions are installed, that you've development your application against.

@allaniftrue

This comment has been minimized.

Show comment
Hide comment
@allaniftrue

allaniftrue Feb 12, 2014

I didn't notice that the framework I was using has listed the composer.lock on the ignore list. Thanks for pointing that out.

I didn't notice that the framework I was using has listed the composer.lock on the ignore list. Thanks for pointing that out.

sndpl pushed a commit to sndpl/composer that referenced this issue Feb 24, 2014

Sandy Pleyte
Updated the troubleshooting doc with a chapter for the proc_fork erro…
…rs that happen on a tiny VPS with no swap space. Also added the solution provided in #1849, #1101, #945.
@PapyDanone

This comment has been minimized.

Show comment
Hide comment
@PapyDanone

PapyDanone Apr 13, 2014

Had the issue today with EC2 micro instance. Increasing PHP memory_limit to 512M fixed it.

Had the issue today with EC2 micro instance. Increasing PHP memory_limit to 512M fixed it.

@allaniftrue

This comment has been minimized.

Show comment
Hide comment
@allaniftrue

allaniftrue Apr 14, 2014

would that be a good thing to do? In digital ocean memory is only 512mb & putting PHP to consume up to such memory would probably dos your own VM.

would that be a good thing to do? In digital ocean memory is only 512mb & putting PHP to consume up to such memory would probably dos your own VM.

@PapyDanone

This comment has been minimized.

Show comment
Hide comment
@PapyDanone

PapyDanone Apr 14, 2014

oh, not at all. No need to mention it's not a production server.

oh, not at all. No need to mention it's not a production server.

@markopavlovic

This comment has been minimized.

Show comment
Hide comment
@markopavlovic

markopavlovic Apr 22, 2014

I was installing a package that required symfony/event-dispatcher, so now I can't install a single package anymore due to the error above :S

I was installing a package that required symfony/event-dispatcher, so now I can't install a single package anymore due to the error above :S

@younes0

This comment has been minimized.

Show comment
Hide comment
@younes0

younes0 Aug 6, 2014

Got this when I enabled opcache.enable_cli in php cli ini

younes0 commented Aug 6, 2014

Got this when I enabled opcache.enable_cli in php cli ini

@KingCrunch

This comment has been minimized.

Show comment
Hide comment
@KingCrunch

KingCrunch Aug 6, 2014

Contributor

@younes0 Thats pretty vague description. Did you read the whole discussion here? Usually it's because you ran out of memory without swap enabled usually within a pretty small cloud-instance, or VM.

Contributor

KingCrunch commented Aug 6, 2014

@younes0 Thats pretty vague description. Did you read the whole discussion here? Usually it's because you ran out of memory without swap enabled usually within a pretty small cloud-instance, or VM.

@younes0

This comment has been minimized.

Show comment
Hide comment
@younes0

younes0 Aug 6, 2014

@KingCrunch in my case, it wasn't related to insufficient memory, I got the error described by @yooper when I tried to install composer packages with the opcache.enable_cli php option set to On (VM or not)

younes0 commented Aug 6, 2014

@KingCrunch in my case, it wasn't related to insufficient memory, I got the error described by @yooper when I tried to install composer packages with the opcache.enable_cli php option set to On (VM or not)

@pioneerwebsites

This comment has been minimized.

Show comment
Hide comment
@pioneerwebsites

pioneerwebsites Jun 3, 2015

I have the same error but with a large instance: 4gb RAM and 4gb swap. The free RAM is never exhausted, let alone the available/cached RAM, and the swap isn't touched!

It's the first time running composer update on this new machine, CentOS/CloudLinux 7.1.

Any ideas? Please?

I have the same error but with a large instance: 4gb RAM and 4gb swap. The free RAM is never exhausted, let alone the available/cached RAM, and the swap isn't touched!

It's the first time running composer update on this new machine, CentOS/CloudLinux 7.1.

Any ideas? Please?

@vjroby

This comment has been minimized.

Show comment
Hide comment
@vjroby

vjroby Jul 7, 2015

I had the same error running in my Vagrant Box. I had 2gb of ram when I got the error. I extended the ram to 4gb and it worked. But, still it's weird that it needs so much ram.

vjroby commented Jul 7, 2015

I had the same error running in my Vagrant Box. I had 2gb of ram when I got the error. I extended the ram to 4gb and it worked. But, still it's weird that it needs so much ram.

@allaniftrue

This comment has been minimized.

Show comment
Hide comment
@allaniftrue

allaniftrue Jul 16, 2015

I ran into this problem again and adding the composer.lock didn't work. But instead I tried to use swap space instead of extending much memory. An article on digitalocean is quite nifty https://www.digitalocean.com/community/tutorials/how-to-configure-virtual-memory-swap-file-on-a-vps

I ran into this problem again and adding the composer.lock didn't work. But instead I tried to use swap space instead of extending much memory. An article on digitalocean is quite nifty https://www.digitalocean.com/community/tutorials/how-to-configure-virtual-memory-swap-file-on-a-vps

@c9s

This comment has been minimized.

Show comment
Hide comment
@c9s

c9s Aug 30, 2015

I also encountered the problem:

PHP Warning:  proc_open(): fork failed - Cannot allocate memory in phar:///home/...../sculpin.phar/vendor/symfony/console/Symfony/Component/Console/Application.php on line 974

My memory_limit is set to -1

my free output:

             total       used       free     shared    buffers     cached
Mem:          1992       1331        660        122          8        217
-/+ buffers/cache:       1105        886
Swap:          255        237         18

c9s commented Aug 30, 2015

I also encountered the problem:

PHP Warning:  proc_open(): fork failed - Cannot allocate memory in phar:///home/...../sculpin.phar/vendor/symfony/console/Symfony/Component/Console/Application.php on line 974

My memory_limit is set to -1

my free output:

             total       used       free     shared    buffers     cached
Mem:          1992       1331        660        122          8        217
-/+ buffers/cache:       1105        886
Swap:          255        237         18
@Hukuta

This comment has been minimized.

Show comment
Hide comment
@Hukuta

Hukuta Sep 26, 2015

I was also having this issue but increasing the PHP memory_limit solved the problem.

me too

Hukuta commented Sep 26, 2015

I was also having this issue but increasing the PHP memory_limit solved the problem.

me too

@dkinzer

This comment has been minimized.

Show comment
Hide comment
@dkinzer

dkinzer Oct 19, 2015

Was running into the same issue with memory_limit set to -1. The only thing that worked for me was reloading my machine.

dkinzer commented Oct 19, 2015

Was running into the same issue with memory_limit set to -1. The only thing that worked for me was reloading my machine.

@koriym

This comment has been minimized.

Show comment
Hide comment
@koriym

koriym Nov 3, 2015

How To Add Swap on Ubuntu 14.04
https://www.digitalocean.com/community/tutorials/how-to-add-swap-on-ubuntu-14-04

This article helped me for 512M RAM instance.

koriym commented Nov 3, 2015

How To Add Swap on Ubuntu 14.04
https://www.digitalocean.com/community/tutorials/how-to-add-swap-on-ubuntu-14-04

This article helped me for 512M RAM instance.

@i-allan

This comment has been minimized.

Show comment
Hide comment
@i-allan

i-allan Nov 18, 2015

[Solved] If you are running this in virtual machine, Stop the virtual machine either by vagrant halt command or by graceful stop.

Change RAM size as per your application, In my case i updated memory to 1024MB.
default it was 256MB;

i.e it worked

i-allan commented Nov 18, 2015

[Solved] If you are running this in virtual machine, Stop the virtual machine either by vagrant halt command or by graceful stop.

Change RAM size as per your application, In my case i updated memory to 1024MB.
default it was 256MB;

i.e it worked

@sergiohermes

This comment has been minimized.

Show comment
Hide comment
@sergiohermes

sergiohermes Feb 10, 2016

Stop mysql httpd or nginx service and run again

Run composer

And restart services

Stop mysql httpd or nginx service and run again

Run composer

And restart services

@KingCrunch

This comment has been minimized.

Show comment
Hide comment
@KingCrunch

KingCrunch Feb 10, 2016

Contributor

HI @sergiohermes

This only works, when nginx and/or mysql coincidentally consumes that much memory, that composer misses. Also stopping essential services is probably not an option in most cases. You should really invest in memory, either physically, or in form of a swap partition/file. It's all already documented in this thread.

Contributor

KingCrunch commented Feb 10, 2016

HI @sergiohermes

This only works, when nginx and/or mysql coincidentally consumes that much memory, that composer misses. Also stopping essential services is probably not an option in most cases. You should really invest in memory, either physically, or in form of a swap partition/file. It's all already documented in this thread.

@sergiohermes

This comment has been minimized.

Show comment
Hide comment
@sergiohermes

sergiohermes Feb 24, 2016

I understand, anyway it was a way without having to swap.
The most appropriate but is to create a swap. Without a doubt.
Taking a look found for "centos" an interesting reference.

https://www.digitalocean.com/community/tutorials/additional-recommended-steps-for-new-centos-7-servers

I believe will add this thread.

I understand, anyway it was a way without having to swap.
The most appropriate but is to create a swap. Without a doubt.
Taking a look found for "centos" an interesting reference.

https://www.digitalocean.com/community/tutorials/additional-recommended-steps-for-new-centos-7-servers

I believe will add this thread.

@lostguo

This comment has been minimized.

Show comment
Hide comment
@lostguo

lostguo Apr 22, 2016

Oh,I use swap solve it,thanks

lostguo commented Apr 22, 2016

Oh,I use swap solve it,thanks

@mohitg-bs

This comment has been minimized.

Show comment
Hide comment
@mohitg-bs

mohitg-bs May 5, 2016

You can avoid this either by increasing the memory size from php.ini file, which is a wrong option. Better delete the cache and rebuild the packages.

Delete composer cache: `sudo rm -R ~/.composer`
Delete vendor folder: `sudo rm -R vendor`
Rebuild the vendor packages: `composer update`

Or, I can be done by:

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

mohitg-bs commented May 5, 2016

You can avoid this either by increasing the memory size from php.ini file, which is a wrong option. Better delete the cache and rebuild the packages.

Delete composer cache: `sudo rm -R ~/.composer`
Delete vendor folder: `sudo rm -R vendor`
Rebuild the vendor packages: `composer update`

Or, I can be done by:

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

@KingCrunch

This comment has been minimized.

Show comment
Hide comment
@KingCrunch

KingCrunch May 10, 2016

Contributor

@mohitg-bs I guess you mixed something up

  • Removing files doesn't free up RAM
  • It's not about PHPs memory_limit, but the (virtual) memory from the entire system. There is no ini setting, that can create you RAM.
Contributor

KingCrunch commented May 10, 2016

@mohitg-bs I guess you mixed something up

  • Removing files doesn't free up RAM
  • It's not about PHPs memory_limit, but the (virtual) memory from the entire system. There is no ini setting, that can create you RAM.
@oussaka

This comment has been minimized.

Show comment
Hide comment
@oussaka

oussaka May 15, 2016

I solved the same problem in Vagrant.

I easily Increased Memory on Vagrant Virtual Machine http://www.josheaton.org/increase-memory-vagrant-virtual-machine/
then, I increased the value of memory_limit
and delete composer cache: sudo rm -R ~/.composer
and finally vagrant reload.

oussaka commented May 15, 2016

I solved the same problem in Vagrant.

I easily Increased Memory on Vagrant Virtual Machine http://www.josheaton.org/increase-memory-vagrant-virtual-machine/
then, I increased the value of memory_limit
and delete composer cache: sudo rm -R ~/.composer
and finally vagrant reload.

@gnufred

This comment has been minimized.

Show comment
Hide comment
@gnufred

gnufred Jun 13, 2016

I had the same problem on a Virtual Box running through Vagrant.
Fixed by increasing VBox ram.

Config change from vb.memory = 512 to vb.memory = 1024

gnufred commented Jun 13, 2016

I had the same problem on a Virtual Box running through Vagrant.
Fixed by increasing VBox ram.

Config change from vb.memory = 512 to vb.memory = 1024

@reddimohan

This comment has been minimized.

Show comment
Hide comment
@reddimohan

reddimohan Aug 21, 2016

I have added swap memory and it solved my issue.

I have added swap memory and it solved my issue.

@gillera235

This comment has been minimized.

Show comment
Hide comment
@gillera235

gillera235 Oct 18, 2016

You ran out of swap memory, try this

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

You ran out of swap memory, try this

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

@shamun

This comment has been minimized.

Show comment
Hide comment
@shamun

shamun Nov 1, 2016

To add a swap file:

Determine the size of the new swap file in megabytes and multiply by 1024 to determine the number of blocks. For example, the block size of a 64 MB swap file is 65536.
At a shell prompt as root, type the following command with count being equal to the desired block size:
dd if=/dev/zero of=/swapfile bs=1024 count=65536
Setup the swap file with the command:
mkswap /swapfile
To enable the swap file immediately but not automatically at boot time:
swapon /swapfile
To enable it at boot time, edit /etc/fstab to include the following entry:
/swapfile swap swap defaults 0 0
The next time the system boots, it enables the new swap file.

After adding the new swap file and enabling it, verify it is enabled by viewing the output of the command cat /proc/swaps or free.

shamun commented Nov 1, 2016

To add a swap file:

Determine the size of the new swap file in megabytes and multiply by 1024 to determine the number of blocks. For example, the block size of a 64 MB swap file is 65536.
At a shell prompt as root, type the following command with count being equal to the desired block size:
dd if=/dev/zero of=/swapfile bs=1024 count=65536
Setup the swap file with the command:
mkswap /swapfile
To enable the swap file immediately but not automatically at boot time:
swapon /swapfile
To enable it at boot time, edit /etc/fstab to include the following entry:
/swapfile swap swap defaults 0 0
The next time the system boots, it enables the new swap file.

After adding the new swap file and enabling it, verify it is enabled by viewing the output of the command cat /proc/swaps or free.

@dnorenavega-EDR

This comment has been minimized.

Show comment
Hide comment

thank you!

aminztw pushed a commit to aminztw/composer that referenced this issue Jan 1, 2017

Sandy Pleyte
Updated the troubleshooting doc with a chapter for the proc_fork erro…
…rs that happen on a tiny VPS with no swap space. Also added the solution provided in #1849, #1101, #945.
@therobyouknow

This comment has been minimized.

Show comment
Hide comment
@therobyouknow

therobyouknow Apr 5, 2017

Tips - if adding swap doesn't solve the composer out of memory/couldn't allocate error:

  • Restart your machine after adding swap. I found composer error didn't go away after adding 8G of swap. But after restarting it worked.
  • I also shut down another VM I was running and closed Chrome with too many tabs

(I'm using composer in a development environment on macOS X Sierra 10.12.4 with 16Gb RAM).

Tips - if adding swap doesn't solve the composer out of memory/couldn't allocate error:

  • Restart your machine after adding swap. I found composer error didn't go away after adding 8G of swap. But after restarting it worked.
  • I also shut down another VM I was running and closed Chrome with too many tabs

(I'm using composer in a development environment on macOS X Sierra 10.12.4 with 16Gb RAM).

@artforlife

This comment has been minimized.

Show comment
Hide comment
@artforlife

artforlife Apr 5, 2017

Has this been resolved? I have updated the Composer globally. In addition, I created a 1GB swap space per @gillera235 suggestion. I still get the same error. What can I do to troubleshoot it?

If it helps, I am using a free-tier micro EC2 instance.

artforlife commented Apr 5, 2017

Has this been resolved? I have updated the Composer globally. In addition, I created a 1GB swap space per @gillera235 suggestion. I still get the same error. What can I do to troubleshoot it?

If it helps, I am using a free-tier micro EC2 instance.

@macpatel

This comment has been minimized.

Show comment
Hide comment
@macpatel

macpatel Jun 7, 2017

push the composer.lock file on your server and do

composer --verbose install

this way it didn't take much memory and was superfast to install the updated packges according to versions in the composer.lock file.

macpatel commented Jun 7, 2017

push the composer.lock file on your server and do

composer --verbose install

this way it didn't take much memory and was superfast to install the updated packges according to versions in the composer.lock file.

@sagarshah16

This comment has been minimized.

Show comment
Hide comment
@sagarshah16

sagarshah16 Aug 17, 2017

it happens when you have less memory
try these steps
1)service mysql stop
2) run your comment
3)service mysql start

it happens when you have less memory
try these steps
1)service mysql stop
2) run your comment
3)service mysql start

@vjroby

This comment has been minimized.

Show comment
Hide comment
@vjroby

vjroby Aug 28, 2017

@sagarshah16 What happens if I don't have a mysql service?

vjroby commented Aug 28, 2017

@sagarshah16 What happens if I don't have a mysql service?

@sagarshah16

This comment has been minimized.

Show comment
Hide comment
@sagarshah16

sagarshah16 Aug 28, 2017

try to find which one of your running services takes more memory space. if it is not mysql.

try to find which one of your running services takes more memory space. if it is not mysql.

@brutalcrozt

This comment has been minimized.

Show comment
Hide comment
@brutalcrozt

brutalcrozt Sep 5, 2017

yeah ig update composer should solve the problem, sadly i update via git bash. It always throw same error to update. So to windows users just make sure use cmd.exe.

yeah ig update composer should solve the problem, sadly i update via git bash. It always throw same error to update. So to windows users just make sure use cmd.exe.

@resting

This comment has been minimized.

Show comment
Hide comment
@resting

resting Dec 7, 2017

Hit the error earlier. Was on Ubuntu 16.04 on a EC2 micro instance.
Solved by adding a 1G swap file.

resting commented Dec 7, 2017

Hit the error earlier. Was on Ubuntu 16.04 on a EC2 micro instance.
Solved by adding a 1G swap file.

@nadeemse

This comment has been minimized.

Show comment
Hide comment
@sergiohermes

This comment has been minimized.

Show comment
Hide comment
@sergiohermes

sergiohermes Jan 16, 2018

$ apt install swapspace 
$ cat /etc/os-release 
NAME="Ubuntu"
VERSION="16.04.3 LTS (Xenial Xerus)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 16.04.3 LTS"
VERSION_ID="16.04"
HOME_URL="http://www.ubuntu.com/"
SUPPORT_URL="http://help.ubuntu.com/"
BUG_REPORT_URL="http://bugs.launchpad.net/ubuntu/"
VERSION_CODENAME=xenial
UBUNTU_CODENAME=xenial

Reference:
http://manpages.ubuntu.com/manpages/xenial/man8/swapspace.8.html

Thank you Jeroen T. Vermeulen

Enthusiasm is the light of knowledge.
Unknown author.
O estusiasmo é luz do conhecimento.
Autor desconhecido.
$ apt install swapspace 
$ cat /etc/os-release 
NAME="Ubuntu"
VERSION="16.04.3 LTS (Xenial Xerus)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 16.04.3 LTS"
VERSION_ID="16.04"
HOME_URL="http://www.ubuntu.com/"
SUPPORT_URL="http://help.ubuntu.com/"
BUG_REPORT_URL="http://bugs.launchpad.net/ubuntu/"
VERSION_CODENAME=xenial
UBUNTU_CODENAME=xenial

Reference:
http://manpages.ubuntu.com/manpages/xenial/man8/swapspace.8.html

Thank you Jeroen T. Vermeulen

Enthusiasm is the light of knowledge.
Unknown author.
O estusiasmo é luz do conhecimento.
Autor desconhecido.
@richRemer

This comment has been minimized.

Show comment
Hide comment
@richRemer

richRemer Jan 22, 2018

This issue can be exacerbated by not having memory over-commit enabled. Forking is massively inefficient without memory over-commit. Essentially when you fork, you double the committed memory usage of your current process by creating another identical process. Much of this memory is shared between the parent and child processes, but is copy-on-write, so any writes will cause the shared memory to get copied. When over-commit is enabled, your system allows this duplicated shared memory, but if you write to the shared memory, you might not have enough physical RAM to handle the copy. With over-commit disabled, your system won't allow you to allocate the memory in the first place.

richRemer commented Jan 22, 2018

This issue can be exacerbated by not having memory over-commit enabled. Forking is massively inefficient without memory over-commit. Essentially when you fork, you double the committed memory usage of your current process by creating another identical process. Much of this memory is shared between the parent and child processes, but is copy-on-write, so any writes will cause the shared memory to get copied. When over-commit is enabled, your system allows this duplicated shared memory, but if you write to the shared memory, you might not have enough physical RAM to handle the copy. With over-commit disabled, your system won't allow you to allocate the memory in the first place.

@ctrl-f5

This comment has been minimized.

Show comment
Hide comment
@ctrl-f5

ctrl-f5 Jul 9, 2018

Getting this error with 1.4GIG available...

$ free -m; composer require --dev phpro/grumphp
              total        used        free      shared  buff/cache   available
Mem:           2000         416        1277          21         305        1405
Swap:             0           0           0
Using version ^0.14.1 for phpro/grumphp
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 12 installs, 0 updates, 0 removals
  - Installing symfony/dependency-injection (v3.4.11): The following exception is caused by a lack of memory or swap, or not having swap configured
Check https://getcomposer.org/doc/articles/troubleshooting.md#proc-open-fork-failed-errors for details

                                                     
  [ErrorException]                                   
  proc_open(): fork failed - Cannot allocate memory

ctrl-f5 commented Jul 9, 2018

Getting this error with 1.4GIG available...

$ free -m; composer require --dev phpro/grumphp
              total        used        free      shared  buff/cache   available
Mem:           2000         416        1277          21         305        1405
Swap:             0           0           0
Using version ^0.14.1 for phpro/grumphp
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 12 installs, 0 updates, 0 removals
  - Installing symfony/dependency-injection (v3.4.11): The following exception is caused by a lack of memory or swap, or not having swap configured
Check https://getcomposer.org/doc/articles/troubleshooting.md#proc-open-fork-failed-errors for details

                                                     
  [ErrorException]                                   
  proc_open(): fork failed - Cannot allocate memory
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment