Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Clear visitedCollections #703

Merged
merged 1 commit into from

4 participants

@shulcsm

Visited collections are cleared only in commit(). Commit clears up only if it actually has something to do. Processing large amounts of records without changing them cause visitedCollections to grow without any way of clearing.

@shulcsm shulcsm Clear visitedCollections
Visited collections are cleared only in commit(). Commit clears up only if it actually has something to do. Processing large amounts of records without changing them cause visitedCollections to grow without any way of clearing.
3340234
@stof

could you add a test for this ?

@Ocramius
Owner

@stof can't really test this one since there's no way to access the visited collections...

@beberlei
Owner

This explains why some people have memory leaks even when using clear.

@beberlei
Owner

@shulcsm have you tested that this is actually the case in visitedCollections. I can't come up with a flow diagram of how this state is actually reached. The property is only set, when you call flush on the EntityManager.

@shulcsm

@beberlei
Early return point here https://github.com/doctrine/doctrine2/blob/master/lib/Doctrine/ORM/UnitOfWork.php#L315 cause this.

To reproduce:
1) Select existing entity
2) Add new associated entities
3) Remove associated entities
4) Flush (There are no actual data, so commit returns at L315 without reaching the clear at L381)
5) Clear
uow should be empty, visitedCollections are still there.

@beberlei beberlei merged commit 29d6da0 into doctrine:master
@shulcsm shulcsm deleted the shulcsm:patch-1 branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jun 19, 2013
  1. @shulcsm

    Clear visitedCollections

    shulcsm authored
    Visited collections are cleared only in commit(). Commit clears up only if it actually has something to do. Processing large amounts of records without changing them cause visitedCollections to grow without any way of clearing.
This page is out of date. Refresh to see the latest.
Showing with 1 addition and 0 deletions.
  1. +1 −0  lib/Doctrine/ORM/UnitOfWork.php
View
1  lib/Doctrine/ORM/UnitOfWork.php
@@ -2356,6 +2356,7 @@ public function clear($entityName = null)
$this->collectionUpdates =
$this->extraUpdates =
$this->readOnlyObjects =
+ $this->visitedCollections =
$this->orphanRemovals = array();
if ($this->commitOrderCalculator !== null) {
Something went wrong with that request. Please try again.