I\'m having trouble in locating the cause for a memory leak in my script. I have a simple repository method which increments a \'count\' column in my entity by X amount:
For me it was clearing doctrine, or as the documentation says, detaching all entities:
$this->em->clear(); //Here em is the entity manager.
So inside my loop y flush every 1000 iterations and detach all entities (I don't need them anymore):
foreach ($reader->getRecords() as $position => $value) {
$this->processValue($value, $position);
if($position % 1000 === 0){
$this->em->flush();
$this->em->clear();
}
$this->progress->advance();
}
Hope this helps.
PS: here's the documentation.