Browse Source

Restore GC and add comments to clarify why we turn it off, fixes #3488, closes #3503

Jordi Boggiano 9 years ago
parent
commit
c2d78e5ce0
1 changed files with 9 additions and 0 deletions
  1. 9 0
      src/Composer/Installer.php

+ 9 - 0
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;
     }