Closed
Description
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) {
//...
}
}
}