Open
Description
Doctrine needs to be smarter about avoiding memory exhaustion with profiling enabled.
I thought I had a severe memory leak in my script, but I traced it back to the profiling setting for Doctrine. When enabled, I lose about a megabyte of PHP memory for every file that I need to parse and persist. In situations where I need to process hundreds of files, that means my only option is to globally disable the profiling setting to prevent memory allocation errors.
Is it possible to change Doctrine to clear the profiler when clearing the ORM?
Is it possible to change Doctrine to have a configurable size limit for profiling?
Is it possible to change Doctrine so that profiling can be disabled at run time?
Activity
stof commentedon May 27, 2025
An existing option to reduce memory usage is to disable collecting the backtrace (which would mean that the profiler would not show you the backtrace for each executed query, removing one tool allowing you to know why that query was executed).
Clearing the profiler when clearing the entity manager or limiting its size would mean that the collected data is incomplete, which could lead to misleading.
For the last point, the solution implemented in symfony/symfony#60243 in Symfony 7.3 should be adopted for the Doctrine collector.
miqrogroove commentedon May 27, 2025
Let's frame this in the context of forcing memory allocation errors. I don't care about the completeness of collected backtraces as the script comes crashing down. Is there some middle ground of flexibility where we can optionally clear the profiler?