diff --git a/src/Composer/Installer.php b/src/Composer/Installer.php index 7aadb01a1..ace3fa17b 100644 --- a/src/Composer/Installer.php +++ b/src/Composer/Installer.php @@ -163,6 +163,10 @@ class Installer */ public function run() { + // Disable GC to save CPU cycles, as the dependency solver can create hundreds of thousands + // of PHP objects, the GC can spend quite some time walking the tree of references looking + // for stuff to collect while there is nothing to collect. This slows things down dramatically + // and turning it off results in much better performance. Do not try this at home however. gc_collect_cycles(); gc_disable(); @@ -341,6 +345,11 @@ class Installer } } + // re-enable GC except on HHVM which triggers a warning here + if (!defined('HHVM_VERSION')) { + gc_enable(); + } + return 0; }