Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Symfony2 memory leaks and performance issues #2938

vyarmolenko opened this issue Mar 28, 2016 · 1 comment

Symfony2 memory leaks and performance issues #2938

vyarmolenko opened this issue Mar 28, 2016 · 1 comment


Copy link

@vyarmolenko vyarmolenko commented Mar 28, 2016

I wrote some functional tests for Symfony2 app with multiple requests in a test and encountered an issue with test failing due to lack of memory (3GB's was not enough to complete the test). I rewrote my tests and still memory consumption was too big.
The cause of memory leak was the cloning of kernel on each request. it was introduced in #2042 as a solution to problem with service container introduced in #2491.
This issue may relate to the following issues:
#2203 - memory consumption
#2025 - first call to doctrine after client reboot
#2886 - similar memory consumption

Possible issues include:

  • big memory consumption of tests with multiple requests
  • long execution time/slow speed of tests with multiple requests
Copy link

@raistlin raistlin commented Apr 4, 2016

You have made me to spot some issues between Symfony2 module and Symfony2 connector.
First, Symfony2 module declares a public container variable. This variable is never used on the module, but user tests have access to this variable. Problem is that this container instance is never the container linked on the request running kernel. Doctrine works because it is a persisted service and shared among all kernels, but it's a very high trouble.

This container variable is totally invalidated just before first test run, because Symfony2 connector boots a new kernel on every request, and booting a new kernel creates a new container instance. Just before booting a new kernel the connector save persisted services to inject them after kernel has been booted. As a side note, just because kernel is cloned here, kernel on Symfony2 module and Symfony2 connector will be out of sync, other big source of problems.

In conclusion:

  • Symfony2 module do not need the container anymore, if needed we should provide a getContainer method to return current container.
  • Kernel on Symfony2 module and Symfony2 connector will be out of sync, connector should never clone or create a new kernel!

I will create issue to fix the first. The second will reopen #2042, but it's better to reopen and fix it the good way that having memleaks.

Many thanks for your research!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.