Commit 2a62fe22 authored by catch's avatar catch
Browse files

Issue #3492453 by larowlan, catch, longwave, alexpott, godotislate: Memory...

Issue #3492453 by larowlan, catch, longwave, alexpott, godotislate: Memory leak in DrupalKernel when installing modules

(cherry picked from commit 57061f4d)
parent bd2b1c3d
Loading
Loading
Loading
Loading
Loading
+14 −0
Original line number Diff line number Diff line
@@ -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();
  }

}