Skip to content

Instantly share code, notes, and snippets.

@Gasol
Created May 19, 2016 04:28
Show Gist options
  • Save Gasol/d92bfc7d09adeb2f694a43e0adc76dd0 to your computer and use it in GitHub Desktop.
Save Gasol/d92bfc7d09adeb2f694a43e0adc76dd0 to your computer and use it in GitHub Desktop.
<?php
// scripts to reproduce memory leak on https://github.com/guzzle/guzzle/issues/1151
require __DIR__ . '/vendor/autoload.php';
use Sunra\PhpSimple\HtmlDomParser;
use GuzzleHttp\Client;
$urls = ['https://www.kkbox.com/', 'https://www.kkbox.com/tw/tc/search.php'];
while (true) {
$http = new Client();
shuffle($urls);
$url = $urls[0];
$response = $http->get($url);
$body = $response->getBody();
$parser = new HtmlDomParser(); // FIXME Please put $parser and $http on the outside loop
$html = $parser->str_get_html($body);
$input_word = $html->find('[data-stellar-background-ratio="0.5"]', 0);
$input_word = $html->find('[data-action="up_address"]', 0);
$html->clear();
var_dump(memory_get_usage());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment