We have memory leak problems loading Doctrine in our phpunit tests
Running Symfony documentation: http://symfony.com/doc/2.7/cookbook/testing/doctrine.html we wrote this test:
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; class memoryleakTest extends KernelTestCase { private $em; protected function setUp() { self::bootKernel(); $this->em = static::$kernel->getContainer() ->get('doctrine') ->getManager(); } protected function tearDown() { parent::tearDown(); $this->em->close(); } function testEEE1() { } function testEEE2() { } function testEEE3() { } function testEEE4() { } function testEEE5() { } function testEEE6() { } function testEEE7() { } function testEEE8() { } function testEEE9() { } function testEEE10() { } function testEEE11() { } function testEEE12() { } function testEEE13() { } function testEEE14() { } function testEEE15() { } function testEEE16() { } }
we got this result (php_memory_usage between brackets):
testEEE1: . (42M) testEEE2: . (42.7M) testEEE3: . (43.3M) testEEE4: . (44M) testEEE5: . (44.8M) testEEE6: . (45.5M) testEEE7: . (46.1M) testEEE8: . (46.8M) testEEE9: . (47.4M) testEEE10: . (48.1M) testEEE11: . (48.7M) testEEE12: . (49.4M) testEEE13: . (50.1M) testEEE14: . (50.7M) testEEE15: . (51.4M) testEEE16: . (52M)
If we remove the doctrine manager download in the setup, we got (32.7 M) for each test
Is this the right way to offload the doctrine after each test in the gap function?
symfony phpunit doctrine
Cedric
source share