After upgrade from Symfony 3.1 to Symfony 3.2, memory usage of our phpunit tests increased from ~170MB to 3GB!
I tracked this down to this PR #19656
When we set option php_errors['log'] to false, it decreased to normal level.
We are using lot of functional tests via Symfony\Bundle\FrameworkBundle\Test::createClient
$options parameter for \Symfony\Bundle\FrameworkBundle\Test\WebTestCase::createClient should contain ['debug' => false] value
['debug' => false]
@gadelat Does this fix your issue?
No it doesn't. And even if it did, it's not a proper fix.
just out of curiosity, does the memory usage increase or decrease when replacing https://github.com/symfony/symfony/blob/master/src/Symfony/Component/Debug/ErrorHandler.php#L418-L436 by only $backtrace = $backtrace ?: $errorAsException->getTrace(); (keeping L419 really?)
$backtrace = $backtrace ?: $errorAsException->getTrace();
Not really @nicolas-grekas - It doesn't seem to have noticable effect.
Have you tried the latest patch, 3.2.4?
Could also be fixed by #21061?
No, it even got worse for php_errors['log'] = false after update
Symfony 3.2.3: 107.02MB. Symfony 3.2.4: 221.96MB
#21061 Doesn't help either
So, I found something interesting today. This bug does NOT occur when symfony/phpunit-bridge is installed
EDIT: This is what's causing to stop memory leak: https://github.com/symfony/symfony/blob/e58be70aca039a76706f6ed1e5e820cb113f4ed0/src/Symfony/Bridge/PhpUnit/bootstrap.php#L28