1
0
mirror of synced 2025-01-24 17:21:40 +03:00

don't rely on gc_collect_cycles for HHVM

This commit is contained in:
ptarjan 2013-11-22 01:02:05 -08:00 committed by Benjamin Eberlei
parent 3a8aaea14a
commit 27c9074b71

View File

@ -256,11 +256,10 @@ class IdentityMapTest extends \Doctrine\Tests\OrmFunctionalTestCase
public function testReusedSplObjectHashDoesNotConfuseUnitOfWork() public function testReusedSplObjectHashDoesNotConfuseUnitOfWork()
{ {
$hash1 = $this->subRoutine($this->_em); $hash1 = $this->subRoutine($this->_em);
// Make sure cycles are collected NOW, because a PersistentCollection references if (!defined('HHVM_VERSION')) {
// its owner, hence without forcing gc on cycles now the object will not (yet) // See comment below about PersistentCollection
// be garbage collected and thus the object hash is not reused. gc_collect_cycles();
// This is not a memory leak! }
gc_collect_cycles();
$user1 = new CmsUser; $user1 = new CmsUser;
$user1->status = 'dev'; $user1->status = 'dev';
@ -279,6 +278,17 @@ class IdentityMapTest extends \Doctrine\Tests\OrmFunctionalTestCase
$user->name = 'Roman B.'; $user->name = 'Roman B.';
$em->persist($user); $em->persist($user);
$em->flush(); $em->flush();
// The PersistentCollection references its owner, hence without breaking
// the cycle the object will not (yet) be garbage collected and thus
// the object hash is not reused. This is not a memory leak!
if (defined('HHVM_VERSION')) {
$ed = $this->_em->getUnitOfWork()->getOriginalEntityData($user);
$ed['phonenumbers']->setOwner(null, array('inversedBy' => 1));
$ed['articles']->setOwner(null, array('inversedBy' => 1));
$ed['groups']->setOwner(null, array('inversedBy' => 1));
}
$em->remove($user); $em->remove($user);
$em->flush(); $em->flush();