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:
I had similar issues with a memory leak. I'm running Doctrine in a Symfony 5.2 project. More specific, I built a never-ending Command which is processing entries from one table, retrieves entries from another table, and creates 2 new entries in other tables. (Event Processing)
I solved my leakage problems in two steps.
--no-debug
when running the command (as already suggested by Jonathan)$this->entityManager->clear();
In order to see and identify the leakages, I used the following line to output the current memory usage:
$output->writeln('Memory Usage in MB: ' . memory_get_usage() / 1024 / 1024);
Maybe this helps anyone still fighting with leakages.