今天在运行composer update时遇到的,详细的错误消息如下:
$ composer update
Loading composer repositories with package information
Updating dependencies (including require-dev)
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
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
一直以为是网络原因,最近连接国外的网络不是很稳定,后来根据报错的信息Allowed memory size of 536870912 bytes exhausted提示知道可能是内存分配不够,大家知道在PHP的配置文件php.ini中有限制脚本运行内存的设置memory_limit把这个值调大一些就可以解决这个问题了。
memory_limit = 1G
当然大家也许不喜欢随随便便的改动配置文件php.ini,在帖子《Composer update runs out of memory #1898》Dynom给出了个临时的解决办法:
php -dmemory_limit=1G composer.phar update