Skip to content
This repository has been archived by the owner on Oct 28, 2020. It is now read-only.

Memory leak #5

Open
dinamic opened this issue Oct 7, 2014 · 1 comment
Open

Memory leak #5

dinamic opened this issue Oct 7, 2014 · 1 comment

Comments

@dinamic
Copy link

dinamic commented Oct 7, 2014

I have been investigating why our system workers are dying after a given amount of jobs are processed.

I was able to track the memory leak to this bundle.
Using the guzzle library itself does fix the issue, so it is definitely in the bundle itself.

I have even tried the case with more than 10,000 objects created, as this seem to be the limit after which the garbage collector becomes active, but the issue persists. Reference: https://bugs.php.net/bug.php?id=68132

My use case is as follows:

class SomeClass()
{
    public function someMethod()
    {
        /* @var $response Guzzle\Service\Command\CommandInterface */
        $command = $this->client->getCommand('get_item_by_id', $params);

        /* @var $response Guzzle\Http\Message\Response */
        $response = $command->getResponse();

        return $this->transformResponse($response->getBody(true));
    }

    protected function transformResponce($response)
    {
        /** some code that transforms json to an object */
    }

Replacing some parts of the code by avoiding the bundle seems to fix the case for me:

    $client = new \Guzzle\Http\Client('https://baseurl.com/api');
    $request = $client->get('url.php?id=' . $id);
    $response = $request->send();
@mevdschee
Copy link

Do you have a suggestion on how to fix this? Do you think the code can be improved?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants