Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Clear visitedCollections#703

Merged
beberlei merged 1 commit into
doctrine:masterfrom
shulcsm:patch-1
Jun 30, 2013
Merged

Clear visitedCollections#703
beberlei merged 1 commit into
doctrine:masterfrom
shulcsm:patch-1

Conversation

@shulcsm
Copy link
Copy Markdown
Contributor

@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.

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.
@stof
Copy link
Copy Markdown
Member

stof commented Jun 19, 2013

could you add a test for this ?

@Ocramius
Copy link
Copy Markdown
Member

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

@beberlei
Copy link
Copy Markdown
Member

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

@beberlei
Copy link
Copy Markdown
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
Copy link
Copy Markdown
Contributor Author

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 added a commit that referenced this pull request Jun 30, 2013
@beberlei beberlei merged commit 29d6da0 into doctrine:master Jun 30, 2013
@shulcsm shulcsm deleted the patch-1 branch June 30, 2013 08:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants