Skip to content

[Cache] Memory leak when using the cache #43918

Closed
@Jeroeny

Description

@Jeroeny

Symfony version(s) affected

symfony/framework-bundle:
5.3.10, 5.2.14, 5.1.11, 5.4.x-dev@24649c622776b36158f80b81b9455987b8129793 , 6.0.x-dev@5284b7f8419f9ed224d8d00d6c945d566343cd83, 4.4.31, and I assume every version in between.

PHP: 7.4.15, 8.0.11, 8.0.12, PHP 8.1.0RC5

Description

When using the Symfony cache in a certain way (e.g. calling the cache within a closure that is resolving another cache value), there is a memory leak.

It's quite a strange bug and I don't know what is causing it. I was able to reproduce it (more info in the reproducer's readme). I'm not sure if this could be a PHP bug either.

In the reproducer the memory increase is not that high. However, in our own application the memory increase is ~10 MB per call to the method that does a bunch of caching. This is especially a problem in our message consumers.

I'll test the reproducer against some other Symfony versions too.

How to reproduce

Reproducer: https://github.com/Jeroeny/reproduce/tree/cache

Possible Solution

In our own application gc_collect_cycles() mitigated the problem. But not in the reproducer.

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