Composer Memory Limit

Server environment

1
2
3
4
5
$ cat /etc/issue
Ubuntu 16.04.1 LTS

$ php -v
PHP 7.0.30-0ubuntu0.16.04.1 (cli) ( NTS )

Maybe you have been meet this problem

1
2
3
4
5
...
Reading /home/ubuntu/.cache/....json from cache
Reading /home/ubuntu/.cache/....json from cache
Reading /home/ubuntu/.cache/....json from cache
Killed

Or

1
2
3
4
...
mmap() failed: [12] Cannot allocate memory
PHP Fatal error: Out of memory (allocated 762322944) (tried to allocate 20480 bytes) in phar:///usr/local/bin/composer/src/Composer/DependencyResolver/GenericRule.php on line 36
Fatal error: Out of memory (allocated 762322944) (tried to allocate 20480 bytes) in phar:///usr/local/bin/composer/src/Composer/DependencyResolver/GenericRule.php on line 36

These problems are all due to the need of memory during composer running.

Here are two solution.

Limit PHP Memory

1
$ vim /etc/php/7.0/cli/php.ini
1
memory_limit = 1024M

memory_limit is not limited default in PHP.

Increase Virtual Memory

You can see my another blog
It will show you how to increase the virtual memory in Ubuntu

Thank you for reading.
This post is copyrighted by Liyuliang’s Blog.
If reproduced, please indicate the source: Liyuliang’s Blog
This blog uses Creative Commons Attribution-NonCommercial-Share-Sharing 4.0 International License Agreement to license.


Comments

Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×