找到你要的答案

Q:Memory leak: PHP guzzle/oauth-subscriber

Q:内存泄漏:PHP狂饮/ OAuth用户

When using oauth-subscriber in cron for multiple times their is a memory leak. Here is a basic test I did.

function oauth_1_stack($token = NULL, $token_secret = NULL)
{
    $stack = HandlerStack::create();

    $middleware = new Oauth1([
        'consumer_key'    => 'consumer_key',
        'consumer_secret' => 'consumer_secret',
        'token'           => $token,
        'token_secret'    => $token_secret,
    ]);
    $stack->push($middleware);

    $options = [
      'handler' => $stack,
      'auth' => 'oauth'
    ];

    unset($stack, $middleware);

    return $options;
}

echo memory_get_usage() . "\n"; // 4017480

$options = oauth_1_stack();

echo memory_get_usage() . "\n"; // 4509824

unset($options);

echo memory_get_usage() . "\n"; // 4480032

GitHub issue I logged: https://github.com/guzzle/oauth-subscriber/issues/47

So can I do something to counterfeit this leak?

当用户在使用OAuth cron多次他们是一个内存泄漏。这是我做的基本测试。

function oauth_1_stack($token = NULL, $token_secret = NULL)
{
    $stack = HandlerStack::create();

    $middleware = new Oauth1([
        'consumer_key'    => 'consumer_key',
        'consumer_secret' => 'consumer_secret',
        'token'           => $token,
        'token_secret'    => $token_secret,
    ]);
    $stack->push($middleware);

    $options = [
      'handler' => $stack,
      'auth' => 'oauth'
    ];

    unset($stack, $middleware);

    return $options;
}

echo memory_get_usage() . "\n"; // 4017480

$options = oauth_1_stack();

echo memory_get_usage() . "\n"; // 4509824

unset($options);

echo memory_get_usage() . "\n"; // 4480032

GitHub的问题我登录:https://github.com/guzzle/oauth-subscriber/issues/47

我能做点什么来伪造这个漏洞吗?

php  memory-leaks  oauth  guzzle6