From 66e453aa1b599ed9a35a7b160b89e8f1d1d64541 Mon Sep 17 00:00:00 2001 From: webchick <drupal@webchick.net> Date: Thu, 27 Aug 2015 14:33:28 -0700 Subject: [PATCH] Issue #2503999 by neclimdul, mikeryan, Berdir, catch, andypost: Large volume entity migrations run out of memory --- core/modules/migrate/src/MigrateExecutable.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/core/modules/migrate/src/MigrateExecutable.php b/core/modules/migrate/src/MigrateExecutable.php index fccb667bfcd3..1ed145d53132 100644 --- a/core/modules/migrate/src/MigrateExecutable.php +++ b/core/modules/migrate/src/MigrateExecutable.php @@ -511,7 +511,17 @@ protected function attemptMemoryReclaim() { // First, try resetting Drupal's static storage - this frequently releases // plenty of memory to continue. drupal_static_reset(); + + // Entity storage can blow up with caches so clear them out. + $container = \Drupal::getContainer(); + /** @var \Drupal\Core\Entity\EntityManagerInterface $manager */ + $manager = $container->get('entity.manager'); + foreach ($manager->getDefinitions() as $id => $definition) { + $manager->getStorage($id)->resetCache(); + } + // @TODO: explore resetting the container. + return memory_get_usage(); } -- GitLab