Skip to content
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

Memory limit #3208

Closed
RSully opened this issue Aug 14, 2014 · 10 comments
Closed

Memory limit #3208

RSully opened this issue Aug 14, 2014 · 10 comments

Comments

@RSully
Copy link

RSully commented Aug 14, 2014

Recently I've been consistently hitting composer's 512M limit, so I've created a wrapper composer-infmem that I can use instead.

For slightly bigger projects is it common to consistently hit the limit (on updates/requires)? Is it time to consider lifting the limit from 512M?

(Also worth tagging homebrew/homebrew-php#1210)

@vierbergenlars
Copy link

Composer does not have a 512M memory limit.
If memory_limit in php.ini is smaller than 512M, composer tries to set it to 512M to avoid hitting a PHP memory limit that is too low.
You can always tweak the memory_limit configuration option in php.ini to set a higher limit. Composer will not lower the limit.

@RSully
Copy link
Author

RSully commented Aug 20, 2014

Sorry for wording it that way, I understand it isn't a "limit", as it only sets it to that value if the limit is already below than that.

Coming from a clean OSX install (brew install php55 composer) the result is that by default the upper limit is being enforced by composer's 512M increase since the default PHP memory limit is much lower. It doesn't make sense to me for users to increase the entire system's memory just for composer.

@vierbergenlars
Copy link

Ok, so running composer on your project uses more than 512MB of memory.
Do you happen to have a very large dependency graph? (maybe copy your composer.json so I can try to repro?)
You can check memory usage by using the --profile flag.

@RSully
Copy link
Author

RSully commented Aug 20, 2014

{
    "require": {
        "laravel/framework": "4.2.*",
        "internal/administrator": "*@dev",
        "rhumsaa/uuid": "~2.7"
    },
    "require-dev": {
        "barryvdh/laravel-ide-helper": "1.*",
        "way/generators": "2.*",
        "fzaninotto/faker": "~1.4"
    }
}

internal/administrator is one of our own repositories (defined in repositories as vcs) and its requirements are:

{
    "require": {
        "barryvdh/laravel-ide-helper": "1.*",
        "imagine/imagine": "~0.5.0",
        "anahkiasen/html-object": "~1.4",
        "anahkiasen/underscore-php": "~1.2"
    }
}

The memory limit is hit with the following error:

PHP Fatal error: Allowed memory size of 536870912 bytes exhausted (tried to allocate 32 bytes) in phar:///usr/local/Cellar/composer/1.0.0-alpha8/libexec/composer.phar/src/Composer/DependencyResolver/Rule.php on line 62

@RSully
Copy link
Author

RSully commented Aug 20, 2014

With --profile on my infmem wrapper:

composer-infmem update --profile
[6.8MB/0.06s] Loading composer repositories with package information
[7.5MB/0.55s] Reading compos
[28.2MB/1.80s] Updating dependencies (including require-dev)
[608.3MB/163.65s] Nothing to install or update
[166.9MB/171.00s] Generating autoload files
Generating optimized class loader
Memory usage: 166.93MB (peak: 608.57MB), time: 173.4s

@vierbergenlars
Copy link

Running on my system gives a peak usage of 106MB with the latest version 1e27ff5
Unless your internal repository contains a HUGE amount of branches or tags, I can't immediately see where the trouble comes from.

Possibly the same bug as #2959

@RSully
Copy link
Author

RSully commented Aug 20, 2014

That particular repository is only a master branch without any tags/releases. Perhaps that has something to do with it?

@vierbergenlars
Copy link

IIRC, composer only scans the latest commit on every branch & tag, so that should not be a problem. I have already used VCS repositories with only a master branch without any trouble.

@rk3rn3r
Copy link
Contributor

rk3rn3r commented Aug 25, 2014

to make sure to not hit the php memory limit, set another one with "php -d" and to make sure to get no timeouts you can also add: "COMPOSER_PROCESS_TIMEOUT=60000", sometimes I needed it in case of timeouts

example:

COMPOSER_PROCESS_TIMEOUT=60000 php -d memory_limit=2048M /path/to/composer/composer.phar install

@Seldaek
Copy link
Member

Seldaek commented Sep 20, 2015

limit is now 1GB and we have improved on memory usage quite a bit so closing

@Seldaek Seldaek closed this as completed Sep 20, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants