Skip to content

Commit

Permalink
Add alternative to memory limit
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastian-meyer committed Feb 1, 2024
1 parent 172b473 commit 9dcbbda
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Console/CsvImportCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,8 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$progressIndicator->advance();
$progressIndicator->setMessage('Importing... ' . (string) $count . ' records done.');

// Flush to database if memory usage reaches limit.
if ((memory_get_usage() / $phpMemoryLimit) > $memoryLimit) {
// Flush to database if memory usage reaches limit or every 50.000 records.
if ((memory_get_usage() / $phpMemoryLimit) > $memoryLimit || ($count % 50000) === 0) {
Database::getInstance()->flush([Record::class]);
}
}
Expand Down

0 comments on commit 9dcbbda

Please sign in to comment.