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

High memory usage growing with each consecutive test #78

Open
arrilot opened this issue Jan 3, 2023 · 2 comments
Open

High memory usage growing with each consecutive test #78

arrilot opened this issue Jan 3, 2023 · 2 comments

Comments

@arrilot
Copy link

arrilot commented Jan 3, 2023

Steps to reproduce:

  1. Install basic yii2 template
  2. Add tests https://github.com/arrilot/yii2-codeception-memory-leak-demo/pull/1/files
  3. run vendor/bin/codecept run tests/unit/leak/A500Test.php
Time: 00:02.015, Memory: 156.00 MB
OK (500 tests, 500 assertions)
  1. run vendor/bin/codecept run tests/unit/leak/A1000Test.php
Time: 00:06.381, Memory: 300.00 MB
OK (1000 tests, 1000 assertions)

1000 tests consumed twice as much memory as 500 tests.
Module is not freeing 300kb of memory after each iteration of one test

  1. run both test files - vendor/bin/codecept run tests/unit/leak/
Time: 00:12.377, Memory: 446.00 MB
OK (1500 tests, 1500 assertions)

Module is not freeing 300kb of memory after each test even after all tests in a file were finished

  1. comment Yii2 module out in unit.suite.yml
Time: 00:00.349, Memory: 20.00 MB
OK (1500 tests, 1500 assertions)

Memory usage is 20 smaller

phpinfo.txt

@SamMousa
Copy link
Collaborator

SamMousa commented Jan 3, 2023

Can you try this without the generator? Could also be phpunit which expands the generator for each test case or something. Just to confirm.

@arrilot
Copy link
Author

arrilot commented Jan 10, 2023

This has nothing to do with generator or phpunit because the issue is gone if codeception Yii2 module is turned off
We also face the very same issue with our real test suit consisting of hundreds unique tests and no generators.

In fact. I've managed to find the exact line which results in memory leak

https://github.com/Codeception/module-yii2/blob/master/src/Codeception/Lib/Connector/Yii2.php#L299

If we comment it out:

Time: 00:04.577, Memory: 18.00 MB
OK (1000 tests, 1000 assertions)

With it:

Time: 00:06.544, Memory: 300.00 MB
OK (1000 tests, 1000 assertions)

Looks like a container is leaking a bunch of memory

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants