Clear visitedCollections #703

Merged
merged 1 commit into from Jun 30, 2013

Projects

None yet

4 participants

@shulcsm
shulcsm commented Jun 19, 2013

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
Member
stof commented Jun 19, 2013

could you add a test for this ?

@Ocramius
Member

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

@beberlei
Member

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

@beberlei
Member

@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
shulcsm commented Jun 25, 2013

@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 Jun 30, 2013

1 check failed

Details default The Travis CI build failed
@shulcsm shulcsm deleted the shulcsm:patch-1 branch Jun 30, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment