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

Excessive memory usage in tests #5588

Closed
JABirchall opened this issue Aug 12, 2022 · 17 comments
Closed

Excessive memory usage in tests #5588

JABirchall opened this issue Aug 12, 2022 · 17 comments

Comments

@JABirchall
Copy link

JABirchall commented Aug 12, 2022

Bug Report

Laravel version: 8.73.2
Dbal version: 3.4.0
Phpunit version: 9.5.21

Summary

Durring a recent update our Laravel application, we noticed tests were failing due to trying to allocation 1.3GB in sqliteschememanager.php . this caused our build process and deployments to fail. After forcing dbal to version 3.3.8 memory usage returned to normal, around 90mb.

Current behaviour

SqliteSchemaManager.php Line 252 is causing an excessive memory usage durring unittests.

How to reproduce

Im not really sure. We have around 300 unit tests and 1000+ assertions. Most database access is mocked.

Expected behaviour

Memory usage to not be excessive

@JABirchall JABirchall changed the title dbal 3.4.0 exceesive memory usage in tests dbal 3.4.0 excessive memory usage in tests Aug 12, 2022
@morozov
Copy link
Member

morozov commented Aug 12, 2022

$indexBuffer[] = [

@JABirchall the line you mentioned does what it's supposed to do, so the problem is likely caused by a combination of factors, not a single line.

The DBAL's own tests run with the pdo_sqlite driver in my development environment use the same amount of memory on both the 3.3.8 and 3.4.0 builds.

Could you identify an example of a single test in your suite that causes high memory usage and share it somehow? You can try running a single test with PHPUnit multiple times using the --repeat switch. For example:

$ phpunit --repeat=10 tests/Functional/Schema/SqliteSchemaManagerTest.php
PHPUnit 9.5.21 #StandWithUkraine

........SSSS............S......S................S.....................SS......SSS.S..........SSSS............S......S...... 123 / 850 ( 14%)
..........S.....................SS......SSS.S..........SSSS............S......S................S.....................SS.... 246 / 850 ( 28%)
..SSS.S..........SSSS............S......S................S.....................SS......SSS.S..........SSSS............S.... 369 / 850 ( 43%)
..S................S.....................SS......SSS.S..........SSSS............S......S................S.................. 492 / 850 ( 57%)
...SS......SSS.S..........SSSS............S......S................S.....................SS......SSS.S..........SSSS........ 615 / 850 ( 72%)
....S......S................S.....................SS......SSS.S..........SSSS............S......S................S......... 738 / 850 ( 86%)
............SS......SSS.S..........SSSS............S......S................S.....................SS......SSS.S..            850 / 850 (100%)

Time: 00:00.883, Memory: 20.00 MB

@JABirchall
Copy link
Author

Ill do some more investigating when im back at work on monday.

@masoudniki
Copy link

same problem after upgrading to 3.4.0
solving it by downgrading to 3.3

@derrabus
Copy link
Member

@masoudniki Same request for you: We need a reproducer, otherwise we wouldn't know what to fix.

@morozov
Copy link
Member

morozov commented Aug 14, 2022

@masoudniki there's no need to bump the thread with such comments: it doesn't help maintainers to reproduce the issue and doesn't help the affected users work around it. A "thumbs up" on the issue description would do the same.

@morozov morozov changed the title dbal 3.4.0 excessive memory usage in tests Excessive memory usage in tests Aug 14, 2022
@masoudniki
Copy link

masoudniki commented Aug 15, 2022

sorry for the previous comment

my environment :

laravel v8.83.23
Dbal v3.4.0
phpunit v9.5.21

im running my tests with theses settings

DB_CONNECTION = sqlite
DB_DATABASE=:memory:

this is what I get after running a test with RefreshDatabaseTrait

./vendor/bin/phpunit --filter UserControllerTest --stop-on-failure
PHPUnit Pretty Result Printer 0.30.1 by Codedungeon and contributors.
==> Configuration: ~/Desktop/projects/backend/vendor/codedungeon/phpunit-result-printer/src/phpunit-printer.yml

PHPUnit 9.5.21 #StandWithUkraine


 ==> UserControllerTest         ⚈  

Time: 00:00.106, Memory: 38.50 MB

✖ There was 1 error:

1) Tests\Feature\User\UserControllerTest::test_can_current_user_get_its_details
  ErrorException: Undefined array key -1

/home/masoud/Desktop/projects/backend/vendor/doctrine/dbal/src/Schema/SqliteSchemaManager.php:605
/home/masoud/Desktop/projects/backend/vendor/doctrine/dbal/src/Schema/SqliteSchemaManager.php:206
/home/masoud/Desktop/projects/backend/vendor/doctrine/dbal/src/Schema/AbstractSchemaManager.php:471
/home/masoud/Desktop/projects/backend/vendor/doctrine/dbal/src/Schema/SqliteSchemaManager.php:65
/home/masoud/Desktop/projects/backend/vendor/laravel/framework/src/Illuminate/Database/Schema/Grammars/Grammar.php:317
/home/masoud/Desktop/projects/backend/vendor/laravel/framework/src/Illuminate/Support/helpers.php:263
/home/masoud/Desktop/projects/backend/vendor/laravel/framework/src/Illuminate/Database/Schema/Grammars/Grammar.php:318
/home/masoud/Desktop/projects/backend/vendor/laravel/framework/src/Illuminate/Database/Schema/Grammars/SQLiteGrammar.php:270
/home/masoud/Desktop/projects/backend/vendor/laravel/framework/src/Illuminate/Database/Schema/Blueprint.php:135
/home/masoud/Desktop/projects/backend/vendor/laravel/framework/src/Illuminate/Database/Schema/Blueprint.php:108
/home/masoud/Desktop/projects/backend/vendor/laravel/framework/src/Illuminate/Database/Schema/Builder.php:364
/home/masoud/Desktop/projects/backend/vendor/laravel/framework/src/Illuminate/Database/Schema/Builder.php:211
/home/masoud/Desktop/projects/backend/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php:261
/home/masoud/Desktop/projects/backend/Modules/VPS/Database/migrations/2021_09_19_221446_remove_service_unique_id_fromـvps_console_credentails.php:21
/home/masoud/Desktop/projects/backend/vendor/laravel/framework/src/Illuminate/Database/Migrations/Migrator.php:472
/home/masoud/Desktop/projects/backend/vendor/laravel/framework/src/Illuminate/Database/Migrations/Migrator.php:394
/home/masoud/Desktop/projects/backend/vendor/laravel/framework/src/Illuminate/Database/Migrations/Migrator.php:403
/home/masoud/Desktop/projects/backend/vendor/laravel/framework/src/Illuminate/Database/Migrations/Migrator.php:202
/home/masoud/Desktop/projects/backend/vendor/laravel/framework/src/Illuminate/Database/Migrations/Migrator.php:167
/home/masoud/Desktop/projects/backend/vendor/laravel/framework/src/Illuminate/Database/Migrations/Migrator.php:112
/home/masoud/Desktop/projects/backend/vendor/laravel/framework/src/Illuminate/Database/Console/Migrations/MigrateCommand.php:86
/home/masoud/Desktop/projects/backend/vendor/laravel/framework/src/Illuminate/Database/Migrations/Migrator.php:606
/home/masoud/Desktop/projects/backend/vendor/laravel/framework/src/Illuminate/Database/Console/Migrations/MigrateCommand.php:98
/home/masoud/Desktop/projects/backend/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:36
/home/masoud/Desktop/projects/backend/vendor/laravel/framework/src/Illuminate/Container/Util.php:40
/home/masoud/Desktop/projects/backend/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:93
/home/masoud/Desktop/projects/backend/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:37
/home/masoud/Desktop/projects/backend/vendor/laravel/framework/src/Illuminate/Container/Container.php:653
/home/masoud/Desktop/projects/backend/vendor/laravel/framework/src/Illuminate/Console/Command.php:136
/home/masoud/Desktop/projects/backend/vendor/symfony/console/Command/Command.php:298
/home/masoud/Desktop/projects/backend/vendor/laravel/framework/src/Illuminate/Console/Command.php:121
/home/masoud/Desktop/projects/backend/vendor/symfony/console/Application.php:1024
/home/masoud/Desktop/projects/backend/vendor/symfony/console/Application.php:299
/home/masoud/Desktop/projects/backend/vendor/symfony/console/Application.php:171
/home/masoud/Desktop/projects/backend/vendor/laravel/framework/src/Illuminate/Console/Application.php:94
/home/masoud/Desktop/projects/backend/vendor/laravel/framework/src/Illuminate/Console/Application.php:186
/home/masoud/Desktop/projects/backend/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php:263
/home/masoud/Desktop/projects/backend/vendor/laravel/framework/src/Illuminate/Testing/PendingCommand.php:260
/home/masoud/Desktop/projects/backend/vendor/laravel/framework/src/Illuminate/Testing/PendingCommand.php:413
/home/masoud/Desktop/projects/backend/vendor/laravel/framework/src/Illuminate/Foundation/Testing/Concerns/InteractsWithConsole.php:66
/home/masoud/Desktop/projects/backend/vendor/laravel/framework/src/Illuminate/Foundation/Testing/RefreshDatabase.php:47
/home/masoud/Desktop/projects/backend/vendor/laravel/framework/src/Illuminate/Foundation/Testing/RefreshDatabase.php:21
/home/masoud/Desktop/projects/backend/vendor/laravel/framework/src/Illuminate/Foundation/Testing/TestCase.php:122
/home/masoud/Desktop/projects/backend/vendor/laravel/framework/src/Illuminate/Foundation/Testing/TestCase.php:91
/home/masoud/Desktop/projects/backend/tests/Feature/User/UserControllerTest.php:21

ERRORS!
Tests: 1, Assertions: 0, Errors: 1.

this is the migration class which mentioned in the exception

class RemoveServiceUniqueIdFromـvpsConsoleCredentails extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::table('vps_console_credentials', function (Blueprint $table) {
            $table->dropColumn("service_unique_id");
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::table('vps_console_credentials', function (Blueprint $table) {
            //
        });
    }
}

and here what i get after running the same test for 100 time

 ./vendor/bin/phpunit --repeat 100 --filter UserControllerTest




 ==> UserControllerTest         ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  
                                ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  
                                ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  
                                ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  
                                ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  
                                ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  PHP Fatal error:  Allowed memory size of 134217728 bytes exhausted (tried to allocate 32768 bytes) in /home/masoud/Desktop/projects/backend/bootstrap/app.php on line 1
PHP Fatal error:  Uncaught Illuminate\Contracts\Container\BindingResolutionException: Target [Illuminate\Contracts\Debug\ExceptionHandler] is not instantiable. in /home/masoud/Desktop/projects/backend/vendor/laravel/framework/src/Illuminate/Container/Container.php:1089
Stack trace:
#0 /home/masoud/Desktop/projects/backend/vendor/laravel/framework/src/Illuminate/Container/Container.php(886): Illuminate\Container\Container->notInstantiable()
#1 /home/masoud/Desktop/projects/backend/vendor/laravel/framework/src/Illuminate/Container/Container.php(758): Illuminate\Container\Container->build()
#2 /home/masoud/Desktop/projects/backend/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(851): Illuminate\Container\Container->resolve()
#3 /home/masoud/Desktop/projects/backend/vendor/laravel/framework/src/Illuminate/Container/Container.php(694): Illuminate\Foundation\Application->resolve()
#4 /home/masoud/Desktop/projects/backend/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(836): Illuminate\Container\Container->make()
#5 /home/masoud/Desktop/projects/backend/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php(254): Illuminate\Foundation\Application->make()
#6 /home/masoud/Desktop/projects/backend/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php(185): Illuminate\Foundation\Bootstrap\HandleExceptions->getExceptionHandler()
#7 /home/masoud/Desktop/projects/backend/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php(171): Illuminate\Foundation\Bootstrap\HandleExceptions->renderForConsole()
#8 /home/masoud/Desktop/projects/backend/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php(209): Illuminate\Foundation\Bootstrap\HandleExceptions->handleException()
#9 [internal function]: Illuminate\Foundation\Bootstrap\HandleExceptions->handleShutdown()
#10 {main}
  thrown in /home/masoud/Desktop/projects/backend/vendor/laravel/framework/src/Illuminate/Container/Container.php on line 1089
all these exceptions get fixed after downgrading the Dbal to 3.3

@JABirchall
Copy link
Author

JABirchall commented Aug 15, 2022

Ive done some more investing, here is some stack traces and errors we are seeing.

Single test failure

root@5f0aa44e28b7:/var/www# php vendor/bin/phpunit --filter=DeleteNoiServiceTest            
PHPUnit 9.5.21 #StandWithUkraine

E                                                                   1 / 1 (100%)

Time: 00:01.198, Memory: 40.50 MB

There was 1 error:

1) Tests\Unit\Services\DeleteNoiServiceTest::testDeleteNoiAndAllDataSuccess
Illuminate\Database\QueryException: SQLSTATE[HY000]: General error: 1 near "0": syntax error (SQL: CREATE TABLE city_contact (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, city_id BIGINT UNSIGNED NOT NULL, contact_id INTEGER NOT NULL, primary_contact BOOLEAN NOT NULL, CONSTRAINT 0 FOREIGN KEY (city_id) REFERENCES cities (id) ON UPDATE CASCADE ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE, CONSTRAINT 1 FOREIGN KEY (contact_id) REFERENCES contacts (id) ON UPDATE CASCADE ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE))

/var/www/vendor/laravel/framework/src/Illuminate/Database/Connection.php:703
/var/www/vendor/laravel/framework/src/Illuminate/Database/Connection.php:663
/var/www/vendor/laravel/framework/src/Illuminate/Database/Connection.php:493
/var/www/vendor/laravel/framework/src/Illuminate/Database/Schema/Blueprint.php:109
/var/www/vendor/laravel/framework/src/Illuminate/Database/Schema/Builder.php:365
/var/www/vendor/laravel/framework/src/Illuminate/Database/Schema/Builder.php:212
/var/www/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php:261
/var/www/database/migrations/2022_02_04_151654_change_id_in_cities_table.php:55
/var/www/vendor/laravel/framework/src/Illuminate/Database/Migrations/Migrator.php:394
/var/www/vendor/laravel/framework/src/Illuminate/Database/Migrations/Migrator.php:403
/var/www/vendor/laravel/framework/src/Illuminate/Database/Migrations/Migrator.php:202
/var/www/vendor/laravel/framework/src/Illuminate/Database/Migrations/Migrator.php:167
/var/www/vendor/laravel/framework/src/Illuminate/Database/Migrations/Migrator.php:112
/var/www/vendor/laravel/framework/src/Illuminate/Database/Console/Migrations/MigrateCommand.php:85
/var/www/vendor/laravel/framework/src/Illuminate/Database/Migrations/Migrator.php:585
/var/www/vendor/laravel/framework/src/Illuminate/Database/Console/Migrations/MigrateCommand.php:94
/var/www/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:36
/var/www/vendor/laravel/framework/src/Illuminate/Container/Util.php:40
/var/www/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:93
/var/www/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:37
/var/www/vendor/laravel/framework/src/Illuminate/Container/Container.php:653
/var/www/vendor/laravel/framework/src/Illuminate/Console/Command.php:136
/var/www/vendor/symfony/console/Command/Command.php:298
/var/www/vendor/laravel/framework/src/Illuminate/Console/Command.php:121
/var/www/vendor/symfony/console/Application.php:1024
/var/www/vendor/symfony/console/Application.php:299
/var/www/vendor/symfony/console/Application.php:171
/var/www/vendor/laravel/framework/src/Illuminate/Console/Application.php:94
/var/www/vendor/laravel/framework/src/Illuminate/Console/Application.php:186
/var/www/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php:263
/var/www/vendor/laravel/framework/src/Illuminate/Testing/PendingCommand.php:260
/var/www/vendor/laravel/framework/src/Illuminate/Testing/PendingCommand.php:413
/var/www/vendor/laravel/framework/src/Illuminate/Foundation/Testing/Concerns/InteractsWithConsole.php:66
/var/www/vendor/laravel/framework/src/Illuminate/Foundation/Testing/RefreshDatabase.php:43
/var/www/vendor/laravel/framework/src/Illuminate/Foundation/Testing/RefreshDatabase.php:20
/var/www/vendor/laravel/framework/src/Illuminate/Foundation/Testing/TestCase.php:122
/var/www/vendor/laravel/framework/src/Illuminate/Foundation/Testing/TestCase.php:91
/var/www/tests/Unit/Services/DeleteNoiServiceTest.php:25

Caused by
PDOException: SQLSTATE[HY000]: General error: 1 near "0": syntax error

/var/www/vendor/laravel/framework/src/Illuminate/Database/Connection.php:486
/var/www/vendor/laravel/framework/src/Illuminate/Database/Connection.php:696
/var/www/vendor/laravel/framework/src/Illuminate/Database/Connection.php:663
/var/www/vendor/laravel/framework/src/Illuminate/Database/Connection.php:493
/var/www/vendor/laravel/framework/src/Illuminate/Database/Schema/Blueprint.php:109
/var/www/vendor/laravel/framework/src/Illuminate/Database/Schema/Builder.php:365
/var/www/vendor/laravel/framework/src/Illuminate/Database/Schema/Builder.php:212
/var/www/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php:261
/var/www/database/migrations/2022_02_04_151654_change_id_in_cities_table.php:55
/var/www/vendor/laravel/framework/src/Illuminate/Database/Migrations/Migrator.php:394
/var/www/vendor/laravel/framework/src/Illuminate/Database/Migrations/Migrator.php:403
/var/www/vendor/laravel/framework/src/Illuminate/Database/Migrations/Migrator.php:202
/var/www/vendor/laravel/framework/src/Illuminate/Database/Migrations/Migrator.php:167
/var/www/vendor/laravel/framework/src/Illuminate/Database/Migrations/Migrator.php:112
/var/www/vendor/laravel/framework/src/Illuminate/Database/Console/Migrations/MigrateCommand.php:85
/var/www/vendor/laravel/framework/src/Illuminate/Database/Migrations/Migrator.php:585
/var/www/vendor/laravel/framework/src/Illuminate/Database/Console/Migrations/MigrateCommand.php:94
/var/www/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:36
/var/www/vendor/laravel/framework/src/Illuminate/Container/Util.php:40
/var/www/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:93
/var/www/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:37
/var/www/vendor/laravel/framework/src/Illuminate/Container/Container.php:653
/var/www/vendor/laravel/framework/src/Illuminate/Console/Command.php:136
/var/www/vendor/symfony/console/Command/Command.php:298
/var/www/vendor/laravel/framework/src/Illuminate/Console/Command.php:121
/var/www/vendor/symfony/console/Application.php:1024
/var/www/vendor/symfony/console/Application.php:299
/var/www/vendor/symfony/console/Application.php:171
/var/www/vendor/laravel/framework/src/Illuminate/Console/Application.php:94
/var/www/vendor/laravel/framework/src/Illuminate/Console/Application.php:186
/var/www/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php:263
/var/www/vendor/laravel/framework/src/Illuminate/Testing/PendingCommand.php:260
/var/www/vendor/laravel/framework/src/Illuminate/Testing/PendingCommand.php:413
/var/www/vendor/laravel/framework/src/Illuminate/Foundation/Testing/Concerns/InteractsWithConsole.php:66
/var/www/vendor/laravel/framework/src/Illuminate/Foundation/Testing/RefreshDatabase.php:43
/var/www/vendor/laravel/framework/src/Illuminate/Foundation/Testing/RefreshDatabase.php:20
/var/www/vendor/laravel/framework/src/Illuminate/Foundation/Testing/TestCase.php:122
/var/www/vendor/laravel/framework/src/Illuminate/Foundation/Testing/TestCase.php:91
/var/www/tests/Unit/Services/DeleteNoiServiceTest.php:25

ERRORS!
Tests: 1, Assertions: 0, Errors: 1.

Repeated test failure memory error

root@5f0aa44e28b7:/var/www# php vendor/bin/phpunit --filter=DeleteNoiServiceTest --repeat=300
PHPUnit 9.5.21 #StandWithUkraine

EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE  63 / 300 ( 21%)
EEEEEEEEEEEEEEEEEEEEEEEE
Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 20480 bytes) in /var/www/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Concerns/GuardsAttributes.php on line 247

Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 32768 bytes) in /var/www/vendor/symfony/error-handler/Error/FatalError.php on line 1

Seems to be 2 issues happening here.

  1. incorrect SQL query generation
  2. Maybe some sort of error handling causing memory issue (Possibly not caused by dbal)

@JABirchall
Copy link
Author

Same test on repeat after downgrade

root@5f0aa44e28b7:/var/www# composer update
Loading composer repositories with package information
Updating dependencies
Info from https://repo.packagist.org/: #StandWithUkraine
Lock file operations: 0 installs, 1 update, 0 removals
  - Downgrading doctrine/dbal (3.4.0 => 3.3.8)
Writing lock file
Installing dependencies from lock file (including require-dev)
Package operations: 0 installs, 1 update, 0 removals
  - Downgrading doctrine/dbal (3.4.0 => 3.3.8): Extracting archive
Package swiftmailer/swiftmailer is abandoned, you should avoid using it. Use symfony/mailer instead.
Generating optimized autoload files
> Illuminate\Foundation\ComposerScripts::postAutoloadDump
> @php artisan package:discover --ansi
Discovered Package: facade/ignition
Discovered Package: fideloper/proxy
Discovered Package: fruitcake/laravel-cors
Discovered Package: jamesdordoy/laravelvuedatatable
Discovered Package: laravel-notification-channels/microsoft-teams
Discovered Package: laravel/breeze
Discovered Package: laravel/sail
Discovered Package: laravel/socialite
Discovered Package: laravel/telescope
Discovered Package: laravel/tinker
Discovered Package: laravel/ui
Discovered Package: nesbot/carbon
Discovered Package: nunomaduro/collision
Discovered Package: propaganistas/laravel-phone
Discovered Package: socialiteproviders/manager
Package manifest generated successfully.
90 packages you are using are looking for funding.
Use the `composer fund` command to find out more!

root@5f0aa44e28b7:/var/www# php vendor/bin/phpunit --filter=DeleteNoiServiceTest --repeat=300
PHPUnit 9.5.21 #StandWithUkraine

...............................................................  63 / 300 ( 21%)
............................................................... 126 / 300 ( 42%)
............................................................... 189 / 300 ( 63%)
............................................................... 252 / 300 ( 84%)
................................................                300 / 300 (100%)

Time: 02:22.975, Memory: 58.50 MB

OK (300 tests, 4200 assertions)

@morozov
Copy link
Member

morozov commented Aug 15, 2022

@masoudniki, @JABirchall both your test suites fail due to the issue fixed in #5577. For a clean experiment, could you update the doctrine/dbal package in your environments to 3.4@dev and rerun the tests?

It is quite possible that the test runner used by Laravel buffers the stack traces produced by the exceptions, and en mass, this buffering causes the increase in memory usage.

@masoudniki
Copy link

masoudniki commented Aug 16, 2022

@morozov
thx for your replay
still i get, the same exception after upgrading docrtine/dbal to 3.4.x-dev

running tests without repeat
./vendor/bin/phpunit --filter UserControllerTest::test_can_current_user_get_its_details

result

1) Tests\Feature\User\UserControllerTest::test_can_current_user_get_its_details
  ErrorException: Undefined array key -1

/home/masoud/Desktop/projects/backend/vendor/doctrine/dbal/src/Schema/SqliteSchemaManager.php:605
/home/masoud/Desktop/projects/backend/vendor/doctrine/dbal/src/Schema/SqliteSchemaManager.php:206
/home/masoud/Desktop/projects/backend/vendor/doctrine/dbal/src/Schema/AbstractSchemaManager.php:470
/home/masoud/Desktop/projects/backend/vendor/doctrine/dbal/src/Schema/SqliteSchemaManager.php:65
/home/masoud/Desktop/projects/backend/vendor/laravel/framework/src/Illuminate/Database/Schema/Grammars/Grammar.php:317
/home/masoud/Desktop/projects/backend/vendor/laravel/framework/src/Illuminate/Support/helpers.php:263
/home/masoud/Desktop/projects/backend/vendor/laravel/framework/src/Illuminate/Database/Schema/Grammars/Grammar.php:318
/home/masoud/Desktop/projects/backend/vendor/laravel/framework/src/Illuminate/Database/Schema/Grammars/SQLiteGrammar.php:270
/home/masoud/Desktop/projects/backend/vendor/laravel/framework/src/Illuminate/Database/Schema/Blueprint.php:135
/home/masoud/Desktop/projects/backend/vendor/laravel/framework/src/Illuminate/Database/Schema/Blueprint.php:108
/home/masoud/Desktop/projects/backend/vendor/laravel/framework/src/Illuminate/Database/Schema/Builder.php:364
/home/masoud/Desktop/projects/backend/vendor/laravel/framework/src/Illuminate/Database/Schema/Builder.php:211
/home/masoud/Desktop/projects/backend/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php:261
/home/masoud/Desktop/projects/backend/Modules/VPS/Database/migrations/2021_09_19_221446_remove_service_unique_id_fromـvps_console_credentails.php:21
/home/masoud/Desktop/projects/backend/vendor/laravel/framework/src/Illuminate/Database/Migrations/Migrator.php:472
/home/masoud/Desktop/projects/backend/vendor/laravel/framework/src/Illuminate/Database/Migrations/Migrator.php:394
/home/masoud/Desktop/projects/backend/vendor/laravel/framework/src/Illuminate/Database/Migrations/Migrator.php:403
/home/masoud/Desktop/projects/backend/vendor/laravel/framework/src/Illuminate/Database/Migrations/Migrator.php:202
/home/masoud/Desktop/projects/backend/vendor/laravel/framework/src/Illuminate/Database/Migrations/Migrator.php:167
/home/masoud/Desktop/projects/backend/vendor/laravel/framework/src/Illuminate/Database/Migrations/Migrator.php:112
/home/masoud/Desktop/projects/backend/vendor/laravel/framework/src/Illuminate/Database/Console/Migrations/MigrateCommand.php:86
/home/masoud/Desktop/projects/backend/vendor/laravel/framework/src/Illuminate/Database/Migrations/Migrator.php:606
/home/masoud/Desktop/projects/backend/vendor/laravel/framework/src/Illuminate/Database/Console/Migrations/MigrateCommand.php:98
/home/masoud/Desktop/projects/backend/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:36
/home/masoud/Desktop/projects/backend/vendor/laravel/framework/src/Illuminate/Container/Util.php:40
/home/masoud/Desktop/projects/backend/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:93
/home/masoud/Desktop/projects/backend/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:37
/home/masoud/Desktop/projects/backend/vendor/laravel/framework/src/Illuminate/Container/Container.php:653
/home/masoud/Desktop/projects/backend/vendor/laravel/framework/src/Illuminate/Console/Command.php:136
/home/masoud/Desktop/projects/backend/vendor/symfony/console/Command/Command.php:298
/home/masoud/Desktop/projects/backend/vendor/laravel/framework/src/Illuminate/Console/Command.php:121
/home/masoud/Desktop/projects/backend/vendor/symfony/console/Application.php:1024
/home/masoud/Desktop/projects/backend/vendor/symfony/console/Application.php:299
/home/masoud/Desktop/projects/backend/vendor/symfony/console/Application.php:171
/home/masoud/Desktop/projects/backend/vendor/laravel/framework/src/Illuminate/Console/Application.php:94
/home/masoud/Desktop/projects/backend/vendor/laravel/framework/src/Illuminate/Console/Application.php:186
/home/masoud/Desktop/projects/backend/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php:263
/home/masoud/Desktop/projects/backend/vendor/laravel/framework/src/Illuminate/Testing/PendingCommand.php:260
/home/masoud/Desktop/projects/backend/vendor/laravel/framework/src/Illuminate/Testing/PendingCommand.php:413
/home/masoud/Desktop/projects/backend/vendor/laravel/framework/src/Illuminate/Foundation/Testing/Concerns/InteractsWithConsole.php:66
/home/masoud/Desktop/projects/backend/vendor/laravel/framework/src/Illuminate/Foundation/Testing/RefreshDatabase.php:47
/home/masoud/Desktop/projects/backend/vendor/laravel/framework/src/Illuminate/Foundation/Testing/RefreshDatabase.php:21
/home/masoud/Desktop/projects/backend/vendor/laravel/framework/src/Illuminate/Foundation/Testing/TestCase.php:122
/home/masoud/Desktop/projects/backend/vendor/laravel/framework/src/Illuminate/Foundation/Testing/TestCase.php:91
/home/masoud/Desktop/projects/backend/tests/Feature/User/UserControllerTest.php:21

ERRORS!

running tests with repeat

 ./vendor/bin/phpunit --filter UserControllerTest::test_can_current_user_get_its_details --repeat 10000

result



 ==> UserControllerTest         ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  
                                ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  
                                ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  
                                ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  
                                ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  
                                ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  ⚈  PHP Fatal error:  Allowed memory size of 134217728 bytes exhausted (tried to allocate 20480 bytes) in /home/masoud/Desktop/projects/backend/vendor/laravel/framework/src/Illuminate/Collections/Collection.php on line 695
PHP Fatal error:  Allowed memory size of 134217728 bytes exhausted (tried to allocate 32768 bytes) in /home/masoud/Desktop/projects/backend/vendor/symfony/error-handler/Error/FatalError.php on line 1


@morozov
Copy link
Member

morozov commented Aug 16, 2022

ErrorException: Undefined array key -1

@masoudniki, it doesn't look like you updated the DBAL. This error was supposed to be fixed in #5577.

Please follow the steps in #5584 (comment) and make sure you update the DBAL.

@morozov
Copy link
Member

morozov commented Aug 18, 2022

An issue causing the "Undefined array key -1" error was fixed by #5597. You may want to try re-testing it with the latest ^3.4@dev.

@masoudniki
Copy link

masoudniki commented Aug 23, 2022

@morozov
i update the doctrine/dbal to ^3.4@dev with commit id 22de295f10edbe00df74f517612f1fbd711131e2

as you said the Undefined array key -1 is fixed and my tests are passing but the memory leak still exists

running a test for 1 time

command: ./vendor/bin/phpunit --filter UserControllerTest::test_can_current_user_get_its_details --repeat 1

result:

PHPUnit Pretty Result Printer 0.30.1 by Codedungeon and contributors.
==> Configuration: ~/Desktop/projects/backend/vendor/codedungeon/phpunit-result-printer/src/phpunit-printer.yml

PHPUnit 9.5.23 #StandWithUkraine


 ==> UserControllerTest         ✔  

Time: 00:00.234, Memory: 46.50 MB

OK (1 test, 9 assertions)



running the same test 1000 time

command: ./vendor/bin/phpunit --filter UserControllerTest::test_can_current_user_get_its_details --repeat 1000

result:

PHPUnit Pretty Result Printer 0.30.1 by Codedungeon and contributors.
==> Configuration: ~/Desktop/projects/backend/vendor/codedungeon/phpunit-result-printer/src/phpunit-printer.yml

PHPUnit 9.5.23 #StandWithUkraine


 ==> UserControllerTest         ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  
                                ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  
                                ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  
                                ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  
                                ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  
                                ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  ✔  PHP Fatal error:  Allowed memory size of 134217728 bytes exhausted (tried to allocate 131072 bytes) in /home/masoud/Desktop/projects/backend/vendor/sentry/sentry/src/HttpClient/Plugin/GzipEncoderPlugin.php on line 53
PHP Stack trace:
PHP   1. {main}() /home/masoud/Desktop/projects/backend/vendor/bin/phpunit:0
PHP   2. include() /home/masoud/Desktop/projects/backend/vendor/bin/phpunit:120
PHP   3. PHPUnit\TextUI\Command::main($exit = *uninitialized*) /home/masoud/Desktop/projects/backend/vendor/phpunit/phpunit/phpunit:98
PHP   4. PHPUnit\TextUI\Command->run($argv = [0 => './vendor/bin/phpunit', 1 => '--filter', 2 => 'UserControllerTest::test_can_current_user_get_its_details', 3 => '--repeat', 4 => '1000'], $exit = TRUE) /home/masoud/Desktop/projects/backend/vendor/phpunit/phpunit/src/TextUI/Command.php:96
PHP   5. PHPUnit\TextUI\TestRunner->run($suite = class PHPUnit\Framework\TestSuite { protected $backupGlobals = NULL; protected $backupStaticAttributes = NULL; protected $runTestInSeparateProcess = FALSE; protected $name = ''; protected $groups = ['default' => [...]]; protected $tests = [0 => class PHPUnit\Framework\TestSuite { ... }, 1 => class PHPUnit\Framework\TestSuite { ... }]; protected $numTests = 1; protected $testCase = FALSE; protected $foundClasses = []; protected $providedTests = NULL; protected $requiredTests = NULL; private $beStrictAboutChangesToGlobalState = NULL; private $iteratorFilter = class PHPUnit\Runner\Filter\Factory { private $filters = [...] }; private $declaredClassesPointer = 331; private $warnings = [] }, $arguments = ['extensions' => [], 'listGroups' => FALSE, 'listSuites' => FALSE, 'listTests' => FALSE, 'listTestsXml' => FALSE, 'loader' => NULL, 'useDefaultConfiguration' => TRUE, 'loadedExtensions' => [], 'unavailableExtensions' => [], 'notLoadedExtensions' => [], 'filter' => 'UserControllerTest::test_can_current_user_get_its_details', 'repeat' => 1000, 'testSuffixes' => [0 => 'Test.php', 1 => '.phpt'], 'configuration' => '/home/masoud/Desktop/projects/backend/phpunit.xml', 'configurationObject' => class PHPUnit\TextUI\XmlConfiguration\Configuration { private $filename = '/home/masoud/Desktop/projects/backend/phpunit.xml'; private $validationResult = class PHPUnit\Util\Xml\ValidationResult { ... }; private $extensions = class PHPUnit\TextUI\XmlConfiguration\ExtensionCollection { ... }; private $codeCoverage = class PHPUnit\TextUI\XmlConfiguration\CodeCoverage\CodeCoverage { ... }; private $groups = class PHPUnit\TextUI\XmlConfiguration\Groups { ... }; private $testdoxGroups = class PHPUnit\TextUI\XmlConfiguration\Groups { ... }; private $listeners = class PHPUnit\TextUI\XmlConfiguration\ExtensionCollection { ... }; private $logging = class PHPUnit\TextUI\XmlConfiguration\Logging\Logging { ... }; private $php = class PHPUnit\TextUI\XmlConfiguration\Php { ... }; private $phpunit = class PHPUnit\TextUI\XmlConfiguration\PHPUnit { ... }; private $testSuite = class PHPUnit\TextUI\XmlConfiguration\TestSuiteCollection { ... } }, 'stderr' => FALSE, 'columns' => 80, 'printer' => 'Codedungeon\\PHPUnitPrettyResultPrinter\\Printer'], $warnings = [], $exit = TRUE) /home/masoud/Desktop/projects/backend/vendor/phpunit/phpunit/src/TextUI/Command.php:143
PHP   6. PHPUnit\Framework\TestSuite->run($result = class PHPUnit\Framework\TestResult { private $passed = ['Tests\Feature\User\UserControllerTest::test_can_current_user_get_its_details' => [...]]; private $passedTestClasses = [0 => 'Tests\\Feature\\User\\UserControllerTest', 1 => 'Feature', 2 => '', 3 => 'Tests\\Feature\\User\\UserControllerTest', 4 => 'Feature', 5 => '', 6 => 'Tests\\Feature\\User\\UserControllerTest', 7 => 'Feature', 8 => '', 9 => 'Tests\\Feature\\User\\UserControllerTest', 10 => 'Feature', 11 => '', 12 => 'Tests\\Feature\\User\\UserControllerTest', 13 => 'Feature', 14 => '', 15 => 'Tests\\Feature\\User\\UserControllerTest', 16 => 'Feature', 17 => '', 18 => 'Tests\\Feature\\User\\UserControllerTest', 19 => 'Feature', 20 => '', 21 => 'Tests\\Feature\\User\\UserControllerTest', 22 => 'Feature', 23 => '', 24 => 'Tests\\Feature\\User\\UserControllerTest', 25 => 'Feature', 26 => '', 27 => 'Tests\\Feature\\User\\UserControllerTest', 28 => 'Feature', 29 => '', 30 => 'Tests\\Feature\\User\\UserControllerTest', 31 => 'Feature', 32 => '', 33 => 'Tests\\Feature\\User\\UserControllerTest', 34 => 'Feature', 35 => '', 36 => 'Tests\\Feature\\User\\UserControllerTest', 37 => 'Feature', 38 => '', 39 => 'Tests\\Feature\\User\\UserControllerTest', 40 => 'Feature', 41 => '', 42 => 'Tests\\Feature\\User\\UserControllerTest', 43 => 'Feature', 44 => '', 45 => 'Tests\\Feature\\User\\UserControllerTest', 46 => 'Feature', 47 => '', 48 => 'Tests\\Feature\\User\\UserControllerTest', 49 => 'Feature', 50 => '', 51 => 'Tests\\Feature\\User\\UserControllerTest', 52 => 'Feature', 53 => '', 54 => 'Tests\\Feature\\User\\UserControllerTest', 55 => 'Feature', 56 => '', 57 => 'Tests\\Feature\\User\\UserControllerTest', 58 => 'Feature', 59 => '', 60 => 'Tests\\Feature\\User\\UserControllerTest', 61 => 'Feature', 62 => '', 63 => 'Tests\\Feature\\User\\UserControllerTest', 64 => 'Feature', 65 => '', 66 => 'Tests\\Feature\\User\\UserControllerTest', 67 => 'Feature', 68 => '', 69 => 'Tests\\Feature\\User\\UserControllerTest', 70 => 'Feature', 71 => '', 72 => 'Tests\\Feature\\User\\UserControllerTest', 73 => 'Feature', 74 => '', 75 => 'Tests\\Feature\\User\\UserControllerTest', 76 => 'Feature', 77 => '', 78 => 'Tests\\Feature\\User\\UserControllerTest', 79 => 'Feature', 80 => '', 81 => 'Tests\\Feature\\User\\UserControllerTest', 82 => 'Feature', 83 => '', 84 => 'Tests\\Feature\\User\\UserControllerTest', 85 => 'Feature', 86 => '', 87 => 'Tests\\Feature\\User\\UserControllerTest', 88 => 'Feature', 89 => '', 90 => 'Tests\\Feature\\User\\UserControllerTest', 91 => 'Feature', 92 => '', 93 => 'Tests\\Feature\\User\\UserControllerTest', 94 => 'Feature', 95 => '', 96 => 'Tests\\Feature\\User\\UserControllerTest', 97 => 'Feature', 98 => '', 99 => 'Tests\\Feature\\User\\UserControllerTest', 100 => 'Feature', 101 => '', 102 => 'Tests\\Feature\\User\\UserControllerTest', 103 => 'Feature', 104 => '', 105 => 'Tests\\Feature\\User\\UserControllerTest', 106 => 'Feature', 107 => '', 108 => 'Tests\\Feature\\User\\UserControllerTest', 109 => 'Feature', 110 => '', 111 => 'Tests\\Feature\\User\\UserControllerTest', 112 => 'Feature', 113 => '', 114 => 'Tests\\Feature\\User\\UserControllerTest', 115 => 'Feature', 116 => '', 117 => 'Tests\\Feature\\User\\UserControllerTest', 118 => 'Feature', 119 => '', 120 => 'Tests\\Feature\\User\\UserControllerTest', 121 => 'Feature', 122 => '', 123 => 'Tests\\Feature\\User\\UserControllerTest', 124 => 'Feature', 125 => '', 126 => 'Tests\\Feature\\User\\UserControllerTest', 127 => 'Feature', ...]; private $currentTestSuiteFailed = FALSE; private $errors = []; private $failures = []; private $warnings = []; private $notImplemented = []; private $risky = []; private $skipped = []; private $listeners = [0 => class PHPUnit\Runner\TestListenerAdapter { ... }, 1 => class Codedungeon\PHPUnitPrettyResultPrinter\Printer { ... }, 2 => class PHPUnit\Util\TestDox\HtmlResultPrinter { ... }, 3 => class PHPUnit\Util\TestDox\TextResultPrinter { ... }]; private $runTests = 408; private $time = 47.849167019; private $codeCoverage = NULL; private $convertDeprecationsToExceptions = FALSE; private $convertErrorsToExceptions = TRUE; private $convertNoticesToExceptions = TRUE; private $convertWarningsToExceptions = TRUE; private $stop = FALSE; private $stopOnError = FALSE; private $stopOnFailure = FALSE; private $stopOnWarning = FALSE; private $beStrictAboutTestsThatDoNotTestAnything = TRUE; private $beStrictAboutOutputDuringTests = FALSE; private $beStrictAboutTodoAnnotatedTests = FALSE; private $beStrictAboutResourceUsageDuringSmallTests = FALSE; private $enforceTimeLimit = FALSE; private $forceCoversAnnotation = FALSE; private $timeoutForSmallTests = 1; private $timeoutForMediumTests = 10; private $timeoutForLargeTests = 60; private $stopOnRisky = FALSE; private $stopOnIncomplete = FALSE; private $stopOnSkipped = FALSE; private $lastTestFailed = FALSE; private $defaultTimeLimit = 1; private $stopOnDefect = FALSE; private $registerMockObjectsFromTestArgumentsRecursively = FALSE }) /home/masoud/Desktop/projects/backend/vendor/phpunit/phpunit/src/TextUI/TestRunner.php:673
PHP   7. PHPUnit\Framework\TestSuite->run($result = class PHPUnit\Framework\TestResult { private $passed = ['Tests\Feature\User\UserControllerTest::test_can_current_user_get_its_details' => [...]]; private $passedTestClasses = [0 => 'Tests\\Feature\\User\\UserControllerTest', 1 => 'Feature', 2 => '', 3 => 'Tests\\Feature\\User\\UserControllerTest', 4 => 'Feature', 5 => '', 6 => 'Tests\\Feature\\User\\UserControllerTest', 7 => 'Feature', 8 => '', 9 => 'Tests\\Feature\\User\\UserControllerTest', 10 => 'Feature', 11 => '', 12 => 'Tests\\Feature\\User\\UserControllerTest', 13 => 'Feature', 14 => '', 15 => 'Tests\\Feature\\User\\UserControllerTest', 16 => 'Feature', 17 => '', 18 => 'Tests\\Feature\\User\\UserControllerTest', 19 => 'Feature', 20 => '', 21 => 'Tests\\Feature\\User\\UserControllerTest', 22 => 'Feature', 23 => '', 24 => 'Tests\\Feature\\User\\UserControllerTest', 25 => 'Feature', 26 => '', 27 => 'Tests\\Feature\\User\\UserControllerTest', 28 => 'Feature', 29 => '', 30 => 'Tests\\Feature\\User\\UserControllerTest', 31 => 'Feature', 32 => '', 33 => 'Tests\\Feature\\User\\UserControllerTest', 34 => 'Feature', 35 => '', 36 => 'Tests\\Feature\\User\\UserControllerTest', 37 => 'Feature', 38 => '', 39 => 'Tests\\Feature\\User\\UserControllerTest', 40 => 'Feature', 41 => '', 42 => 'Tests\\Feature\\User\\UserControllerTest', 43 => 'Feature', 44 => '', 45 => 'Tests\\Feature\\User\\UserControllerTest', 46 => 'Feature', 47 => '', 48 => 'Tests\\Feature\\User\\UserControllerTest', 49 => 'Feature', 50 => '', 51 => 'Tests\\Feature\\User\\UserControllerTest', 52 => 'Feature', 53 => '', 54 => 'Tests\\Feature\\User\\UserControllerTest', 55 => 'Feature', 56 => '', 57 => 'Tests\\Feature\\User\\UserControllerTest', 58 => 'Feature', 59 => '', 60 => 'Tests\\Feature\\User\\UserControllerTest', 61 => 'Feature', 62 => '', 63 => 'Tests\\Feature\\User\\UserControllerTest', 64 => 'Feature', 65 => '', 66 => 'Tests\\Feature\\User\\UserControllerTest', 67 => 'Feature', 68 => '', 69 => 'Tests\\Feature\\User\\UserControllerTest', 70 => 'Feature', 71 => '', 72 => 'Tests\\Feature\\User\\UserControllerTest', 73 => 'Feature', 74 => '', 75 => 'Tests\\Feature\\User\\UserControllerTest', 76 => 'Feature', 77 => '', 78 => 'Tests\\Feature\\User\\UserControllerTest', 79 => 'Feature', 80 => '', 81 => 'Tests\\Feature\\User\\UserControllerTest', 82 => 'Feature', 83 => '', 84 => 'Tests\\Feature\\User\\UserControllerTest', 85 => 'Feature', 86 => '', 87 => 'Tests\\Feature\\User\\UserControllerTest', 88 => 'Feature', 89 => '', 90 => 'Tests\\Feature\\User\\UserControllerTest', 91 => 'Feature', 92 => '', 93 => 'Tests\\Feature\\User\\UserControllerTest', 94 => 'Feature', 95 => '', 96 => 'Tests\\Feature\\User\\UserControllerTest', 97 => 'Feature', 98 => '', 99 => 'Tests\\Feature\\User\\UserControllerTest', 100 => 'Feature', 101 => '', 102 => 'Tests\\Feature\\User\\UserControllerTest', 103 => 'Feature', 104 => '', 105 => 'Tests\\Feature\\User\\UserControllerTest', 106 => 'Feature', 107 => '', 108 => 'Tests\\Feature\\User\\UserControllerTest', 109 => 'Feature', 110 => '', 111 => 'Tests\\Feature\\User\\UserControllerTest', 112 => 'Feature', 113 => '', 114 => 'Tests\\Feature\\User\\UserControllerTest', 115 => 'Feature', 116 => '', 117 => 'Tests\\Feature\\User\\UserControllerTest', 118 => 'Feature', 119 => '', 120 => 'Tests\\Feature\\User\\UserControllerTest', 121 => 'Feature', 122 => '', 123 => 'Tests\\Feature\\User\\UserControllerTest', 124 => 'Feature', 125 => '', 126 => 'Tests\\Feature\\User\\UserControllerTest', 127 => 'Feature', ...]; private $currentTestSuiteFailed = FALSE; private $errors = []; private $failures = []; private $warnings = []; private $notImplemented = []; private $risky = []; private $skipped = []; private $listeners = [0 => class PHPUnit\Runner\TestListenerAdapter { ... }, 1 => class Codedungeon\PHPUnitPrettyResultPrinter\Printer { ... }, 2 => class PHPUnit\Util\TestDox\HtmlResultPrinter { ... }, 3 => class PHPUnit\Util\TestDox\TextResultPrinter { ... }]; private $runTests = 408; private $time = 47.849167019; private $codeCoverage = NULL; private $convertDeprecationsToExceptions = FALSE; private $convertErrorsToExceptions = TRUE; private $convertNoticesToExceptions = TRUE; private $convertWarningsToExceptions = TRUE; private $stop = FALSE; private $stopOnError = FALSE; private $stopOnFailure = FALSE; private $stopOnWarning = FALSE; private $beStrictAboutTestsThatDoNotTestAnything = TRUE; private $beStrictAboutOutputDuringTests = FALSE; private $beStrictAboutTodoAnnotatedTests = FALSE; private $beStrictAboutResourceUsageDuringSmallTests = FALSE; private $enforceTimeLimit = FALSE; private $forceCoversAnnotation = FALSE; private $timeoutForSmallTests = 1; private $timeoutForMediumTests = 10; private $timeoutForLargeTests = 60; private $stopOnRisky = FALSE; private $stopOnIncomplete = FALSE; private $stopOnSkipped = FALSE; private $lastTestFailed = FALSE; private $defaultTimeLimit = 1; private $stopOnDefect = FALSE; private $registerMockObjectsFromTestArgumentsRecursively = FALSE }) /home/masoud/Desktop/projects/backend/vendor/phpunit/phpunit/src/Framework/TestSuite.php:672
PHP   8. PHPUnit\Framework\TestSuite->run($result = class PHPUnit\Framework\TestResult { private $passed = ['Tests\Feature\User\UserControllerTest::test_can_current_user_get_its_details' => [...]]; private $passedTestClasses = [0 => 'Tests\\Feature\\User\\UserControllerTest', 1 => 'Feature', 2 => '', 3 => 'Tests\\Feature\\User\\UserControllerTest', 4 => 'Feature', 5 => '', 6 => 'Tests\\Feature\\User\\UserControllerTest', 7 => 'Feature', 8 => '', 9 => 'Tests\\Feature\\User\\UserControllerTest', 10 => 'Feature', 11 => '', 12 => 'Tests\\Feature\\User\\UserControllerTest', 13 => 'Feature', 14 => '', 15 => 'Tests\\Feature\\User\\UserControllerTest', 16 => 'Feature', 17 => '', 18 => 'Tests\\Feature\\User\\UserControllerTest', 19 => 'Feature', 20 => '', 21 => 'Tests\\Feature\\User\\UserControllerTest', 22 => 'Feature', 23 => '', 24 => 'Tests\\Feature\\User\\UserControllerTest', 25 => 'Feature', 26 => '', 27 => 'Tests\\Feature\\User\\UserControllerTest', 28 => 'Feature', 29 => '', 30 => 'Tests\\Feature\\User\\UserControllerTest', 31 => 'Feature', 32 => '', 33 => 'Tests\\Feature\\User\\UserControllerTest', 34 => 'Feature', 35 => '', 36 => 'Tests\\Feature\\User\\UserControllerTest', 37 => 'Feature', 38 => '', 39 => 'Tests\\Feature\\User\\UserControllerTest', 40 => 'Feature', 41 => '', 42 => 'Tests\\Feature\\User\\UserControllerTest', 43 => 'Feature', 44 => '', 45 => 'Tests\\Feature\\User\\UserControllerTest', 46 => 'Feature', 47 => '', 48 => 'Tests\\Feature\\User\\UserControllerTest', 49 => 'Feature', 50 => '', 51 => 'Tests\\Feature\\User\\UserControllerTest', 52 => 'Feature', 53 => '', 54 => 'Tests\\Feature\\User\\UserControllerTest', 55 => 'Feature', 56 => '', 57 => 'Tests\\Feature\\User\\UserControllerTest', 58 => 'Feature', 59 => '', 60 => 'Tests\\Feature\\User\\UserControllerTest', 61 => 'Feature', 62 => '', 63 => 'Tests\\Feature\\User\\UserControllerTest', 64 => 'Feature', 65 => '', 66 => 'Tests\\Feature\\User\\UserControllerTest', 67 => 'Feature', 68 => '', 69 => 'Tests\\Feature\\User\\UserControllerTest', 70 => 'Feature', 71 => '', 72 => 'Tests\\Feature\\User\\UserControllerTest', 73 => 'Feature', 74 => '', 75 => 'Tests\\Feature\\User\\UserControllerTest', 76 => 'Feature', 77 => '', 78 => 'Tests\\Feature\\User\\UserControllerTest', 79 => 'Feature', 80 => '', 81 => 'Tests\\Feature\\User\\UserControllerTest', 82 => 'Feature', 83 => '', 84 => 'Tests\\Feature\\User\\UserControllerTest', 85 => 'Feature', 86 => '', 87 => 'Tests\\Feature\\User\\UserControllerTest', 88 => 'Feature', 89 => '', 90 => 'Tests\\Feature\\User\\UserControllerTest', 91 => 'Feature', 92 => '', 93 => 'Tests\\Feature\\User\\UserControllerTest', 94 => 'Feature', 95 => '', 96 => 'Tests\\Feature\\User\\UserControllerTest', 97 => 'Feature', 98 => '', 99 => 'Tests\\Feature\\User\\UserControllerTest', 100 => 'Feature', 101 => '', 102 => 'Tests\\Feature\\User\\UserControllerTest', 103 => 'Feature', 104 => '', 105 => 'Tests\\Feature\\User\\UserControllerTest', 106 => 'Feature', 107 => '', 108 => 'Tests\\Feature\\User\\UserControllerTest', 109 => 'Feature', 110 => '', 111 => 'Tests\\Feature\\User\\UserControllerTest', 112 => 'Feature', 113 => '', 114 => 'Tests\\Feature\\User\\UserControllerTest', 115 => 'Feature', 116 => '', 117 => 'Tests\\Feature\\User\\UserControllerTest', 118 => 'Feature', 119 => '', 120 => 'Tests\\Feature\\User\\UserControllerTest', 121 => 'Feature', 122 => '', 123 => 'Tests\\Feature\\User\\UserControllerTest', 124 => 'Feature', 125 => '', 126 => 'Tests\\Feature\\User\\UserControllerTest', 127 => 'Feature', ...]; private $currentTestSuiteFailed = FALSE; private $errors = []; private $failures = []; private $warnings = []; private $notImplemented = []; private $risky = []; private $skipped = []; private $listeners = [0 => class PHPUnit\Runner\TestListenerAdapter { ... }, 1 => class Codedungeon\PHPUnitPrettyResultPrinter\Printer { ... }, 2 => class PHPUnit\Util\TestDox\HtmlResultPrinter { ... }, 3 => class PHPUnit\Util\TestDox\TextResultPrinter { ... }]; private $runTests = 408; private $time = 47.849167019; private $codeCoverage = NULL; private $convertDeprecationsToExceptions = FALSE; private $convertErrorsToExceptions = TRUE; private $convertNoticesToExceptions = TRUE; private $convertWarningsToExceptions = TRUE; private $stop = FALSE; private $stopOnError = FALSE; private $stopOnFailure = FALSE; private $stopOnWarning = FALSE; private $beStrictAboutTestsThatDoNotTestAnything = TRUE; private $beStrictAboutOutputDuringTests = FALSE; private $beStrictAboutTodoAnnotatedTests = FALSE; private $beStrictAboutResourceUsageDuringSmallTests = FALSE; private $enforceTimeLimit = FALSE; private $forceCoversAnnotation = FALSE; private $timeoutForSmallTests = 1; private $timeoutForMediumTests = 10; private $timeoutForLargeTests = 60; private $stopOnRisky = FALSE; private $stopOnIncomplete = FALSE; private $stopOnSkipped = FALSE; private $lastTestFailed = FALSE; private $defaultTimeLimit = 1; private $stopOnDefect = FALSE; private $registerMockObjectsFromTestArgumentsRecursively = FALSE }) /home/masoud/Desktop/projects/backend/vendor/phpunit/phpunit/src/Framework/TestSuite.php:672




@morozov
Copy link
Member

morozov commented Aug 23, 2022

@masoudniki thanks for the update. In the hindsight, the recommendation to run tests with --repeat doesn't seem to be the best idea since PHPUnit itself leaks memory by not destructing test objects (e.g. sebastianbergmann/phpunit#4705).

I don't believe we can fix this problem without reproducing it first, and the problem doesn't seem to be reproducible with DBAL alone, so we need to do either of the following:

  1. You share the code where the issue is reproducible and I can try profiling it.
  2. You profile it yourself and provide more details.

I'm open to other ideas as well.

@masoudniki
Copy link

masoudniki commented Aug 24, 2022

@morozov
I appreciate your replay
I believe the memory leak is not related to doctrine/dbal anymore since I installed a fresh install of laravel(9.26.1) and I ran the below test

class ExampleTest extends TestCase
{
    /**
     * A basic test example.
     *
     * @return void
     */
    public function test_example()
    {
        for ($i = 0; $i < 1000; ++$i) {
            $app=$this->createApplication();
            $app->flush();

             preg_match('/^VmRSS:\s(.*)/m', file_get_contents('/proc/self/status'), $m);
             dump("%03d - %.2fMb - %s ". memory_get_usage(true) / 1024 / 1024 ."|||||". trim($m[1]));

        }
    }
}

and the memory starts to grow up on every call on createApplication() method. I also saw some issues with memory leak in laravel (memory leak laravel)

so because I have so many tests the PHPUnit reaches the memory limit and the PHP interpreter crash the process

I guess this issue can be closed

@morozov
Copy link
Member

morozov commented Aug 24, 2022

Thanks for the confirmation, @masoudniki. As we haven't heard back from @JABirchall in a week, I'm going to close this issue. We can reopen it or get a new one filed if the issue still persists.

@morozov morozov closed this as not planned Won't fix, can't repro, duplicate, stale Aug 24, 2022
@github-actions
Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 24, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants