composer / composer

Dependency Manager for PHP
https://getcomposer.org/
MIT License
28.63k stars 4.55k forks source link

I run into memory problems #600

Closed marijn closed 12 years ago

marijn commented 12 years ago
$ composer.phar update
> PHP Fatal error:  Allowed memory size of 134217728 bytes exhausted (tried to allocate 4988760 bytes) in phar:///usr/local/Cellar/composer/HEAD/bin/composer.phar/src/Composer/DependencyResolver/Problem.php on line 36

My composer configuration

{
    "name": "my/app",
    "description": "My app",
    "config": {
        "bin-dir": "bin"
    },
    "require": {
        "php": ">=5.3.2",
        "behat/behat-bundle": "1.0.0",
        "behat/mink-bundle": "dev-master",
        "doctrine/orm": "2.2.*",
        "doctrine/doctrine-bundle": "dev-master",
        "jmikola/insecure-routes-bundle": "dev-master",
        "jms/cg": "dev-master",
        "jms/command-bundle": "dev-master",
        "jms/debugging-bundle": "dev-master",
        "jms/metadata": "1.1.*",
        "jms/security-extra-bundle": "dev-master",
        "jms/serializer-bundle": "dev-master",
        "marijn/spil": "dev-master",
        "knplabs/knp-oauth-bundle": "dev-master",
        "symfony/assetic-bundle": "dev-master",
        "symfony/monolog-bundle": "dev-master",
        "symfony/swiftmailer-bundle": "dev-master",
        "symfony/symfony": "2.1.*",
        "twig/extensions": "dev-master"
    },
    "autoload": {
        "psr-0": {
            "My": "src"
        }
    },
    "repositories": [
        {
            "type": "composer",
            "url": "behat.org"
        },
        {
            "type": "vcs",
            "url": "https://github.com/marijn/Spil"
        }
    ]
}

Composer version: b999d18

willdurand commented 12 years ago

@naderman :

string(20) "Pool::addRepository before: 3458040"
string(19) "Pool::addRepository after: 3569128"
string(20) "Pool::addRepository before: 3569168"
string(19) "Pool::addRepository after: 3617800"
string(20) "Pool::addRepository before: 3617800"
string(19) "Pool::addRepository after: 3711864"          
string(20) "Pool::addRepository before: 3711872"
string(20) "Pool::addRepository after: 27531656"
string(27) "Solver - Memory (usage) before new: 27626896"
string(26) "Solver - Memory (usage) after new: 28034944"
string(30) "Solver - Memory (usage) after solve(): 74714656"
string(30) "Solver - Memory (peak)  after solve(): 93916072"

Average:

naderman commented 12 years ago

Thanks, I have a couple of ideas, will look into it.

ner0tic commented 12 years ago

I'm also encountering this problem

php composer.phar -V Composer version 1a25542

{ "require": { "php": ">=5.3.2", "symfony/symfony": ">=2.1.0-dev", "doctrine/orm": ">=2.2.0-dev", "twig/extensions": "", "symfony/assetic-bundle": "2.0.", "sensio/generator-bundle": "2.0.", "sensio/framework-extra-bundle": "2.0.", "sensio/distribution-bundle": "2.0.", "jms/security-extra-bundle": "1.0." },

"autoload": {
    "psr-0": {
        "Acme": "src/"
    }
}

}

zeroem commented 12 years ago

This appears to be an issue with resolving conflicting versions. I've been able to reproduce this error with the following composer.json:

{
    "name": "a/project",
    "description": "A Project",
    "require": {
        "sonata-project/media-bundle": "dev-master",
        "sonata-project/doctrine-orm-admin-bundle": "2.0.*"
    }
}

Manual inspection of the composer.json files for each project indicates conflicting versions:

media-bundle/dev-master requires symfony 2.1. doctrine-orm-admin-bundle/2.0.* requires symfony 2.0.

The result of running composer.phar install is:

tru-66:derp ramzey$ ./composer.phar install
Installing dependencies
PHP Fatal error:  Allowed memory size of 134217728 bytes exhausted (tried to allocate 6996925 bytes) in phar:///Users/ramzey/derp/composer.phar/src/Composer/DependencyResolver/Problem.php on line 36

Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 6996925 bytes) in phar:///Users/ramzey/derp/composer.phar/src/Composer/DependencyResolver/Problem.php on line 36
ner0tic commented 12 years ago

it was my understanding that most of the dev-master branches are for 2.1

Also, I upgraded composer again after reporting this and temporarily increased my memory allocation and it solved my issues, but still seemed a bit high on the mem usage.

ner0tic commented 12 years ago

Also, I thought i had updated my issue, I upgraded composer again after reporting this and temporarily increased my memory allocation and it solved my issues, but still seemed a bit high on the mem usage.

Shashi-ibuildings commented 12 years ago

Since yesterday, I am also experiencing this issue with composer. Trying to install Behat/Mink using Composer. Not sure if Changing php.ini will solve it ?

$ php composer.phar install

BC warning: your lock file appears to be of an older format than this composer version, it is recommended to run composer update Installing dependencies from lock file PHP Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 2715178 bytes) in phar:///Users/

Any suggestions appreciated .. Thanks

naderman commented 12 years ago

@Seldaek So after the refactoring of the solver, only some packages are needed by the solver anymore. However whatProvides will still need to work correctly which requires the loading of a complete map, however this should open up the possibility to iterate over packages and freeing their memory after to build up the initial map, and to then lazily load packages that are actually needed.

Seldaek commented 12 years ago

I built a phar so that you can test the patch for the memory issues. Given the extensive changes I'd appreciate if a few people try it before we merge this. See https://github.com/composer/composer/pull/1015#issuecomment-7988058 for details.

flymke commented 12 years ago

I had the same issue, actually taking out repositories from composer.json solved the problem for me.. (which wouldn't solve the same for others .... )

frankyw commented 12 years ago

I am also having this problem. Clean install, no lock file or vendor directory.

"require": {
    "symfony/framework-standard-edition": "2.*",
    "monolog/monolog": "1.*",
    "swiftmailer/swiftmailer": "4.*",
    "mopa/bootstrap-bundle": "2.1.x-dev",
    "recaptcha/php5": "dev-master",
    "knplabs/knp-menu-bundle": "2.0.x-dev"
},

Is there any fix yet?

Seldaek commented 12 years ago

This has been addressed recently by #1168 - memory usage is perhaps not optimal yet but it's reduced quite a bit and especially mostly depends on your project complexity now not the amount of packages in packagist.