diff --git a/core/lib/Drupal/Core/Installer/InstallerKernel.php b/core/lib/Drupal/Core/Installer/InstallerKernel.php index 8f4f1c760dee0882ad0cff4f29dd8a5c3fe5d9c8..23f329eff551b67d86f8e2c69ebe7d26bd86e5ad 100644 --- a/core/lib/Drupal/Core/Installer/InstallerKernel.php +++ b/core/lib/Drupal/Core/Installer/InstallerKernel.php @@ -3,6 +3,7 @@ namespace Drupal\Core\Installer; use Drupal\Core\DrupalKernel; +use Symfony\Component\DependencyInjection\ContainerInterface; /** * Extend DrupalKernel to handle force some kernel behaviors. @@ -83,4 +84,17 @@ public static function installationAttempted() { return isset($GLOBALS['install_state']) && empty($GLOBALS['install_state']['installation_finished']); } + /** + * {@inheritdoc} + */ + protected function attachSynthetic(ContainerInterface $container): void { + parent::attachSynthetic($container); + + // Reset any existing container in order to avoid holding on to old object + // references, otherwise memory usage grows exponentially with each rebuild + // when multiple modules are being installed. + // @todo Move this to the parent class after https://www.drupal.org/i/2066993 + $this->container?->reset(); + } + }