\Drupal\Core\Entity\Query\QueryBase never goes out of scope

Created on 16 May 2016, about 9 years ago
Updated 25 July 2025, 12 days ago

Problem/Motivation

\Drupal\Core\Entity\Query\QueryBase and it's children never get destroyed. This is because it's constructor calls \Drupal\Core\Entity\Query\QueryBase::conditionGroupFactory which stores $query (\Drupal\Core\Entity\Query\ConditionFundamentals::__construct) resulting in them never going out of scope (I think).

This causes problems for long running processes such as a Drupal Console Command as, over time, you leak memory.

Proposed resolution

Not sure what the solution is, but from what I can see, the only time $query is used is in \Drupal\Core\Entity\Query\Sql\Condition::compile for:

$tables = $this->query->getTables($sql_query);

Remaining tasks

Work out if we can fix this.

User interface changes

None.

API changes

Unkown.

Data model changes

None.

πŸ› Bug report
Status

Postponed: needs info

Version

11.0 πŸ”₯

Component

entity system

Created by

πŸ‡¬πŸ‡§United Kingdom andrewbelcher

Live updates comments and jobs are added and updated live.
  • stale-issue-cleanup

    To track issues in the developing policy for closing stale issues, [Policy, no patch] closing older issues

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    Thank you for reporting this problem. We rely on issue reports like this one to resolve bugs and improve Drupal core.

    Since there has been no activity here for over 8 years we are asking if this problem persists on a currently supported version of Drupal. To help, add a comment explaining if the problem still occurs or not. Any extra detail you can provide can help others who experienced this.

    Since we need more information to move forward with this issue, the status is now Postponed (maintainer needs more info). If we don't receive additional information to help with the issue, it may be closed after three months.
    Thanks!

Production build 0.71.5 2024