Skip to content

[HttpClient] Memory leak in CurlHttpClient #38492

Closed
@HypeMC

Description

@HypeMC

Symfony version(s) affected: 4.4

Description
The CurlHttpClient has a memory leak which seems to have been caused by this PR #35674 .
When an exception occurs the CurlResponse::close method never gets called from __destruct cause of the PR & the handler never gets unset from the CurlClientState::$openHandles & CurlClientState::$handlesActivity arrays. Over time this leads to a lot of handlers piling up in the memory, causing a memory leak. I've notice this while using the HttpClient in a Messenger handler.

How to reproduce

class MyMessageHandler implements MessageHandlerInterface
{
    //...

    public function doSomething(MyMessage $myMessage): void
    {
        //...
        try {
            $this->httpClient->request(/*...*/);
        } catch (HttpExceptionInterface $e) {
            //...
        }
    }
}

Additional context
image

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