-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Batch Processing using toIterable() #8410
Comments
This is a bug |
beberlei
added a commit
to beberlei/doctrine2
that referenced
this issue
Feb 8, 2021
The new AbstractQuery::toIterable() had a memory leak that AbstractQuery::iterable() did not have. This leak is now fixed. After fixing the leak, one test failed where the identity map in ObjectHydrator triggered and lead to a notice. Introduced a new AbstractHydrator::cleanupAfterRowIteration() that the ObjectHydrator uses to cleanup the state.
beberlei
added a commit
to beberlei/doctrine2
that referenced
this issue
Feb 16, 2021
The new AbstractQuery::toIterable() had a memory leak that AbstractQuery::iterable() did not have. This leak is now fixed. After fixing the leak, one test failed where the identity map in ObjectHydrator triggered and lead to a notice. Introduced a new AbstractHydrator::cleanupAfterRowIteration() that the ObjectHydrator uses to cleanup the state.
beberlei
added a commit
to beberlei/doctrine2
that referenced
this issue
Feb 16, 2021
beberlei
added a commit
that referenced
this issue
Feb 16, 2021
* [GH-8410] Fix memory leak in new toIterable and state bug. The new AbstractQuery::toIterable() had a memory leak that AbstractQuery::iterable() did not have. This leak is now fixed. After fixing the leak, one test failed where the identity map in ObjectHydrator triggered and lead to a notice. Introduced a new AbstractHydrator::cleanupAfterRowIteration() that the ObjectHydrator uses to cleanup the state. * [GH-8413] Bugfix: Iterating with multiple, mixed results When multiple entity results are part of a row, the result handling must be different. In addition mixed results with scalars are broken and now throw an exception as illegal operation. * Housekeeping: phpcs * [GH-8413] Add assertions for entity alias iteration. * [GH-8387] Missing @deprecated on Query::iterate
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi all!
I've updated my application to Doctrine ORM 2.8 some days ago.
Before that, my Repository code to iterate through a large result set looked like the following and worked perfectly even on >500.000 rows without leaking any memory.
Since
Query::iterate()
is deprecated now, I tried to useQuery::toIterable()
as suggested.With this implementation I stumbled over a massive memory leak in my application. I debugged this and found out that the
AbstractHydrator
is never releasing the Objects inAbstractHydrator::toIterable()
. The called methodAbstractHydrator::hydrateRowData()
(or in my caseSimpleObjectHydrator::hydrateRowData
) just adds new entries to$result
.orm/lib/Doctrine/ORM/Internal/Hydration/AbstractHydrator.php
Line 177 in 378944d
orm/lib/Doctrine/ORM/Internal/Hydration/SimpleObjectHydrator.php
Line 157 in 378944d
Is that the intended behaviour? Wouldn't it be better to clear
$result
in every loop cycle to free memory?If that's intended, is there a better way to loop through large result sets?
The text was updated successfully, but these errors were encountered: