Skip to content

[FrameworkBundle] Memory leak in PHPUnit when testing forms on entities #45668

Closed
@adrienfr

Description

@adrienfr

Symfony version(s) affected

5.4.6

Description

Hi,

Since SF 5.4.6 on PHP 7.4.26, I have a memory leak on PHPUnit and my large tests suite (4981 tests, 33361 assertions) fails with this error :

PHP Fatal error: Allowed memory size of 1073741824 bytes exhausted

I tried to debug it and it seems to origin from #45595.

cc @nicolas-grekas

How to reproduce

I created a reproducer to compare SF 5.4.5 and 5.4.6, accessible here.
The memory leak seems to happen on Form tests with entities having relationship/association type properties.

Additional Context

The reproducer entity only contains 1 ManyToOne property and used memory is x2, in my project (with 1Gb of RAM dedicated to PHPUnit tests) here is the result when testing a single Form on an entity with 10+ relationship properties :

SF 5.4.5 :

Testing 
.Memory usage: 146 MB
.Memory usage: 161 MB
.Memory usage: 171 MB
.Memory usage: 152 MB
.Memory usage: 161 MB
.Memory usage: 151 MB
.Memory usage: 151 MB
.Memory usage: 151 MB
.Memory usage: 160 MB
.Memory usage: 151 MB
.Memory usage: 151 MB
.Memory usage: 152 MB
.Memory usage: 162 MB
.Memory usage: 152 MB
.Memory usage: 152 MB
.Memory usage: 151 MB
.Memory usage: 161 MB
.Memory usage: 151 MB
.Memory usage: 151 MB
.Memory usage: 151 MB
.Memory usage: 160 MB
21 / 21 (100%)

Time: 00:09.343, Memory: 207.00 MB

SF 5.4.6:

Testing 
.Memory usage: 147 MB
.Memory usage: 163 MB
.Memory usage: 173 MB
.Memory usage: 184 MB
.Memory usage: 193 MB
.Memory usage: 202 MB
.Memory usage: 212 MB
.Memory usage: 222 MB
.Memory usage: 231 MB
.Memory usage: 240 MB
.Memory usage: 249 MB
.Memory usage: 260 MB
.Memory usage: 271 MB
.Memory usage: 281 MB
.Memory usage: 292 MB
.Memory usage: 302 MB
.Memory usage: 311 MB
.Memory usage: 322 MB
.Memory usage: 332 MB
.Memory usage: 341 MB
.Memory usage: 350 MB
21 / 21 (100%)

Time: 00:09.034, Memory: 373.00 MB

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions