symfony: [DoctrineBridge] EntityType memory leak in functional tests
Symfony version(s) affected: 5.2 (also 5.1)
Description
When running multiple functional tests that request pages that include forms using an EntityType
, there is a memory leak. Does not occur with symfony/doctrine-bridge
5.0.x.
How to reproduce Reproducer (readme has instructions).
Possible Solution I’m looking for help tracking down the problem. I think it’s caused by https://github.com/symfony/symfony/pull/34550 and/or https://github.com/symfony/symfony/pull/30994 but I’m not positive.
I think, in your tests, when browsing multiple pages, one or more of which has a form that includes an EntityType
, it is not cleaned up/reset between requests.
Additional context
- Blackfire comparison of the reproducer between
symfony/doctrine-bridge
5.0 and 5.2. Nothing jumped out at me but I don’t have any experience with blackfire. - https://github.com/symfony/symfony/issues/38890 seems very related.
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 17 (17 by maintainers)
Commits related to this issue
- bug #45479 [HttpKernel] Reset services between requests performed by KernelBrowser (nicolas-grekas) This PR was merged into the 4.4 branch. Discussion ---------- [HttpKernel] Reset services between... — committed to symfony/symfony by fabpot 2 years ago
- bug #45595 [FrameworkBundle] Fix resetting container between tests (nicolas-grekas) This PR was merged into the 4.4 branch. Discussion ---------- [FrameworkBundle] Fix resetting container between t... — committed to symfony/symfony by nicolas-grekas 2 years ago
Found it! See #45479
I’ve also discovered some things about the
reset()
:kernel.reset
tag to theform.type.entity
service still does not trigger the resetself::$container->get('form.type.entity')->reset();
to my test case’s tearDown() doesn’t solve the issue (it executes the method but doesn’t fix the memory leak)Thank you for the application Kevin. This really helps a lot understanding the issue. I spent quite some time on this debugging what’s going on. One thing that I noticed is that the
reset()
method is never called though I do not have any idea how to fix that yet.Sorry for not commenting earlier. This issue is on my list, but I am a bit busy currently. I hope to be able to look into it soon.