Abbiamo problemi con perdita di memoria durante il caricamento Dottrina nei nostri test PHPUnitSymfony e PHPUnit perdita di memoria
di partenza per la documentazione di Symfony: http://symfony.com/doc/2.7/cookbook/testing/doctrine.html che abbiamo scritto questo 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() {
}
}
abbiamo ottenuto questo risultato (php_memory_usage tra parentesi):
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)
Se togliamo il carico dottrina manager in setup, abbiamo ottenuto (32,7M) per ogni prova
È un modo corretto di scaricare la dottrina dopo ogni test nella funzione di teardown?
mi sembra a posto. hai comunque qualche roba arricciata? che mi ha causato perdite di memoria catastrofiche – DevDonkey
@DevDonkey nient'altro che esattamente nulla nel test: nessun arricciamento, nessun accesso al database ... semplicemente chiamando la dottrina senza usarla (quindi forse carica tutti i metadati). Sembra che tutte queste informazioni caricate in memoria non vengano rilasciate, anche con un kernel-> shutdown() – Cedric