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

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 17 (17 by maintainers)

Commits related to this issue

Most upvoted comments

Found it! See #45479

I’ve also discovered some things about the reset():

  1. Adding the kernel.reset tag to the form.type.entity service still does not trigger the reset
  2. Adding self::$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.