3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo { private $orig; public function bar() { $this->orig = clone $this; } } $foo = new Foo; $history = array(); $last = 0; for ($i = 0; $i < 5000; $i++) { $foo->bar(); gc_collect_cycles(); $peak = round(memory_get_peak_usage(true) / 1024 / 1024, 2); if ($peak != $last) { $history[] = $peak; $last = $peak; } } var_dump($history);

preferences:
27.57 ms | 402 KiB | 5 Q