don't rely on gc_collect_cycles for HHVM
This commit is contained in:
parent
3a8aaea14a
commit
27c9074b71
@ -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();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user