Baldinof / roadrunner-bundle

A RoadRunner worker integrated in your Symfony app
MIT License
255 stars 46 forks source link

Empty symfony 6.2 leaking memory #95

Closed rmikalkenas closed 1 year ago

rmikalkenas commented 1 year ago

Hi all!

I started playing around roadrunner for http requests and noticed a memory leak on completely empty symfony application. Created a reproducer: https://github.com/rmikalkenas/roadrunner-leak-reproducer Has anyone faced similar issue and could guide me what's wrong here

php -v
PHP 8.1.14 (cli) (built: Jan 11 2023 08:10:46) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.1.14, Copyright (c) Zend Technologies
    with Zend OPcache v8.1.14, Copyright (c), by Zend Technologies
    with Xdebug v3.2.0, Copyright (c) 2002-2022, by Derick Rethans
    with ddtrace v0.82.0, Copyright Datadog, by Datadog
    with ddappsec v0.4.5, Copyright Datadog, by Datadog
./rr -v               
rr version 2.12.2 (build time: 2023-01-12T12:07:45+0000, go1.19.5), OS: linux, arch: amd64

Edit: Tried to disable Datadog and Xdebug extensions: result the same, memory_get_usage increases between requests

Edit2: Managed to solve memory leak with a middleware:

public function process(Request $request, HttpKernelInterface $next): \Iterator
{
    try {
        yield $next->handle($request);
    } finally {
        \gc_collect_cycles();
    }
}
rmikalkenas commented 1 year ago

Closing in favor of https://github.com/roadrunner-server/roadrunner/discussions/1458