2

When I try to install a package to Contao using the Composer client I get an error:

Fatal error: Allowed memory size of 1073741824 bytes exhausted (tried to allocate 134217728 bytes) in phar://D:/wamp/www/myproject/composer/composer.phar/src/Composer/DependencyResolver/Solver.php on line 220

I am really confused. My PHP memory limit is set at 512M. phpinfo() confirms it. But 1073741824 is a gigabyte! And it still isn't enough, as if the script totally disregards the PHP memory limit (where?) and even a gigabyte isn't enough!?!?

What can I do? I read about RLimitMEM, but I can not find such a setting anywhere on WAMPServer.

2 Answers 2

1

I found the answer.

I searched the project for memory_limit and found out, that the composer client attempts to set a memory limit in system/modules/!composer/src/Runtime.php There is this line: @ini_set('memory_limit', '1024M'); I changed it to @ini_set('memory_limit', '2048M'); essentially doubling the available memory, and it worked.

Sign up to request clarification or add additional context in comments.

2 Comments

I have to comment here that I think it is absolutely appalling that a PHP script uses that much memory. I just don't get it.
It's the dependency resolving part of Composer. Due to the success of the composer package management platform there are a lot of packages in a multitude of versions out there now. Depending on your composer.json settings (minimum-stability) this results in a large complexity, which in turn requires a lot of memory. See github.com/composer/composer/issues/1898 and other tickets for example.
1

It is recommended to use the so called detached mode for the composer client. If you have a proper CLI environment available, you'll have no memory limit and no maximum execution time. Also both of these limits can be controlled via command line arguments.

However, this does not work in all hosting environments. See this Wiki entry for more details: https://github.com/contao-community-alliance/composer-client/wiki/Execution-modes

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.