Skip to content

Profiling Memory Errors #1881

Open
Open
@miqrogroove

Description

@miqrogroove

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

stof commented on May 27, 2025

@stof
Member

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

miqrogroove commented on May 27, 2025

@miqrogroove
Author

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.

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @stof@miqrogroove

        Issue actions

          Profiling Memory Errors · Issue #1881 · doctrine/DoctrineBundle