symfony: Memory leak when using route annotation

Symfony version(s) affected: v4.3.2 (tested also 3.4 and 4.2, same issue)

Description
When a route is defined using annotations, there is a memory leak. If the route is defined using YAML, there is no memory leak.

How to reproduce
I have created a basic symfony app available in https://github.com/goetas/symfony-mem-leak The travis build showing the memory leak https://travis-ci.org/goetas/symfony-mem-leak/jobs/551313488

The test app has a basic controller as follows:

class DefaultController
{
    /**
     * @Route("/leak",name="getss")
     * @return Response
     */
    public function leak()
    {
        return new Response('hello');
    }

    public function noleak()
    {
        return new Response('hello');
    }
}

Requests to leak will result in a memory leak, requests to noleak will have no leaks.

The repo includes 2 scripts bin/runner-no-leak and bin/runner-no-leak that call 5000 times the two routes.

When bin/runner-leak is called, memory goes up.

In larger application memory goes up faster… apparently depending on the output of the method…

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 21 (20 by maintainers)

Commits related to this issue

Most upvoted comments

Thanks for working on this! I have verified your PR and seems working. Here is the build on Travis and here the branch that uses your cache-fix branch

I have reduced it to a minimal version that leaks on my machine, but does not on travis.