diff --git a/Command/ReindexCommand.php b/Command/ReindexCommand.php index ca15552a..75d20de7 100644 --- a/Command/ReindexCommand.php +++ b/Command/ReindexCommand.php @@ -199,10 +199,22 @@ protected function indexDocuments(string $locale, IndexerInterface $indexer, Out $progressBar = new ProgressBar($output, $count); $progressBar->setFormat(' %current%/%max% [%bar%] %percent:3s%% %elapsed:6s%/%estimated:-6s% %memory:6s%'); $progressBar->start(); + $count = 0; foreach ($documents as $document) { $indexer->index($document); $progressBar->advance(); + + ++$count; + + if (0 === ($count % 100)) { + $indexer->flush(); + $this->documentManager->clear(); + } + + if (0 === ($count % 500)) { + \gc_collect_cycles(); + } } $indexer->flush();