diff --git a/core/lib/Drupal/Core/DrupalKernel.php b/core/lib/Drupal/Core/DrupalKernel.php index 0c16cb35cc116908b0ca451872ed3c08a3319149..fdb3d86885e6d20e31a5a647d671a6f8da84d6d8 100644 --- a/core/lib/Drupal/Core/DrupalKernel.php +++ b/core/lib/Drupal/Core/DrupalKernel.php @@ -821,6 +821,13 @@ protected function initializeContainer() { // If there is no container and no cached container definition, build a new // one from scratch. if (!isset($container) && !isset($container_definition)) { + if (version_compare(phpversion(), '7.0.0-dev') >= 0) { + // The service graph implementation is prone to corruption during GC. + // Collect cycles now then disable the GC for the time of the compiler + // run. + // @see https://bugs.php.net/bug.php?id=70805 + gc_collect_cycles(); + } $container = $this->compileContainer(); // Only dump the container if dumping is allowed. This is useful for